Monday 6 May 2013

Program In C to Check Whether A Number Is Armstrong Number Or Not


#include<stdio.h>
#include<conio.h>
void main()
{
int num,r,sum=0,temp;
clrscr();

printf("Enter a number: ");
scanf("%d",&num);

temp=num;
while(num!=0)
{
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("%d is an Armstrong number",temp);
else
printf("%d is not an Armstrong number",temp);

getch();
}

No comments:

Post a Comment