Multiprogramming Language Trainer
Wednesday, 9 November 2016
C Program to Find the armstrong of a number
#include<stdio.h>
#include<conio.h>
main()
{
int
n,r,sum=0,temp;
clrscr();
printf(
"enter the number="
);
scanf(
"%d"
,&n);
temp=n;
while
(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if
(temp==sum)
printf(
"armstrong number "
);
else
printf(
"not armstrong number"
);
getch();
}
Output:
enter the number=153 armstrong number
enter the number=5 not armstrong number
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment