Friday, 19 September 2014

WAP to check the no. is Armstrong or not.

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,k,x;
printf("Enter the no. to find the no. is armstrong or not : ");
scanf("%d",&a);
b=a;
int m=0;
while(b>0)
{
k=b%10;
m=m+k*k*k;
b=b/10;

}
if(m==a)
{
printf("%d is Armstrong no.",a);

}       else
{
printf("%d is not Armstrong no.",a);
}
getch();
}

No comments:

Post a Comment

Please write your doubts