100 Most Important C# Programs
37. Program to accept a number and check the given number Armstrong or not
Code:
# include <stdio.h>
# include <conio.h>
main( )
{
int n,arm;
clrscr();
printf(“enter any 3 digit number:”)
scanf(“%d”,&n);
arm= armstrong(n);
if(arm= =n)
printf(“%d is Armstrong number”,n);
else
printf(“%d not a Armstrong number”,n);
getch( );
}
int Armstrong (int n)
{
int a,b,c,d;
a=n/100;
b=((n/10)%10);
c=n%10;
d=a*a*a+b*b*b+c*c*c;
return d;
}