Program to check Armstrong number

#include<stdio.h>
#include<conio.h>
int main()
{
int i=2,temp,rem,sum=0 ,n;
clrscr();
printf("Enter any number");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
}
if(temp==sum)
printf("\n the numbers is an Armstrong Number");
else
printf("\n Not an Armstrong Number");
getch();
return 0;
}

0 comments:

Post a Comment