Thursday, March 8, 2012

Entered no is Armstrong no or not.

//Entered no is Armstrong no or not.
#include<stdio.h>
#include<conio.h>
main()
{ int d,r,n,s;
 printf("Enter no:");
 scanf("%d",&n);
 d=n;
 s=0;
do
 {
  r=d%10;
  d=d/10;
  s=s+(r*r*r);
 }while(d!=0);
 if(s==n)
 printf("Armstrong no");
 else
 printf("Not Armstrong no");
getch();
}

No comments:

Post a Comment