Template by:
Free Blog Templates

Saturday, November 7, 2009

Check Armstrong Number | C Programming

//wap to check if the no is Armstrong
#include
#include
void main()
{
int n=0,x,arm=0,r; //students are advised to use
clrscr(); // “long” instead of “int” so as to use high figure no
printf(“\n\n enter a number: “);
scanf(“%d”,&n);
x=n;
while(x!=0){
r=x%10;
x=x/10;
arm=arm + pow(r,3);}
if(arm==n)
{printf(“\n Armstrong Number : %d”,arm);}
else
{printf(“\n Not Armstrong ”);}
}
o/p→
enter a number : 157
Armstrong : 157








0 comments:

Post a Comment

If you have any proble fee free to ask it here