Saturday, March 10, 2012

Write a program to check whether a given number is armstrong or not.




#include  
#include  
void main()
{
 int a,b,y,m,q;
printf(“Enter any no. \n”);
scanf(“%d”,&a);
 b=a;
y=0;
while(b!=0)
{
 m=b%10;
 q=b/10;
 y=y+(m*m*m);
 b=q;
}
if(y==a)
{
printf(“ The no. is Armstrong\n”); printf("%d\n",a);
}
else
{


printf(“ The no. is not Armstrong\n”); printf("%d\n",a);
}
getch();

}

No comments:

Post a Comment

Sociable