Saturday, 26 September 2015

Program to find enter number Armstrong or not

/*Program to find enter number Armstrong or not*/
#include<conio.h>
#include<stdio.h>
void main()
{
int sum=0,n,x,r;
clrscr();
printf("Enter any number:");
scanf("%d",&n);
x=n;
while(n>0)
{
r=n%10;
sum=sum+r*r*r;
n=n/10;

}
if(sum==x)
printf("Armstrong number");
else
printf("is not a armstrong number");
getch();
}


No comments:

Post a Comment