Armstrong no. in C programming

Accept a no. and check if it is Armstrong or not:


#include<stdio.h>
#include<conio.h>


void main()
{
int no,rem,sum=0,ori;
clrscr();
printf("Enter a no:");
scanf("%d",&no);
ori=no;
while(no>0)
{
rem=no%10;
sum=sum+rem*rem*rem;
no=no/10;
}
if(ori==sum)
printf("Armstrong no");
else
printf("Not Armstrong no");
getch();
}


More C-programs >>>

No comments:

Post a Comment

Thanks for visiting my Blog!

Have a Question ? Need Help in College Assignments, Need Code that is not available here? Just leave a comment & get your code instantly.

Tips to Enhance Your Blog