#include
int main()
{
int n, n1, rem, num=0;
clrscr();
printf("Enter a positive integer : ");
scanf("%d", &n);
n1=n;
while(n1!=0)
{
rem=n1%10;
num+=rem*rem*rem;
n1/=10;
}
if(num==n)
printf("\n%d is an Armstrong number.",n);
else
printf("\n%d is not an Armstrong number.",n);
getch();
}
Alogithm
step1:start
step2:intialize num<-0 p="">step3:Read n
step4:n1=n
step5:check whether n1!=0,then go to step 6
else go to step 10
step6:rem=n1%10
step7:num=num+rem*rem*rem
step8:n1=n1/10
step9:go to step 5
step10:check whether num =n,then go to step 11
else go to step 12
step11:print armstrong number
step12:print not armstrong number
step13:stop
-0>
Very informative article.Thank you author for posting this kind of article .
ReplyDeletehttp://www.wikitechy.com/view-article/c-program-to-check-armstrong-number-with-example-and-explanation
Both are really good,
Cheers,
Venkat