Tuesday, September 15, 2015

Filled Under:

C program to check whether a number is Armstrong

Share
#include<stdio.h>
#include<conio.h>
void main()
{
 int num,r,sum=0,temp;
clrscr();
printf("Enter a number:\n");
scanf("%d",&num);
temp=num;
while(num!=0)
{
r=num%10;
sum=sum+(r*r*r);
num=num/10;
}
if(sum==temp)
printf("The number is Armstrong");
else
printf("The number is not Armstrong");
getch();
}

0 comments:

Post a Comment