Here you will get program for armstrong number in C.
Armstrong number is n digits number whose sum of digits raised to power n is equal to itself.
For example:
371 is armstrong number because 33 + 73 + 13 = 27 + 343 +1 = 371.
Program for Armstrong Number in C
#include<stdio.h> #include<math.h> int main() { int n,m=0,p=0,x,y; printf("Enter any number: "); scanf("%d",&n); y=n; while(y!=0){ y=y/10; p++; } y=n; while(n!=0) { x=n%10; m+=pow(x,p); n=n/10; } if(y==m) printf("The given number is an armstrong number"); else printf("The given number is not an armstrong number"); return 0; }
Output
Enter any number: 371
The given number is an armstrong number