What is Armstrong Number?
- A number N is an Armstrong number of order n (n being the number of digits)
- if abed. . . = a^n + b^n + e^n + d^n .+ . . . = N .
- The number 153 is an Armstrong number of order 3 because
- l^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153.
- Likewise, 54748 is an Armstrong number of order 5 because
- 5^5 + 4^5 + 7^5 + 4^5 + 8^5 = 3125 + 1024 + 16807 + 1024 + 32768 = 54748.
- #include<stdio.h>
- int main()
- {
- int n;
- int r;
- int sum=0;
- int temp;
- printf("Enter a number \n");
- scanf("%d",&n);
- temp=n;
- while(n>0)
- {
- r=n%10;
- sum=sum+(r*r*r);
- n=n/10;
- }
- if(temp == sum)
- printf("Number is a armstrong number\n");
- else
- printf("Number is NOT a armstrong number\n");
- return 0;
- }
0 Comments
If you have any doubts, Please let me know