C Program to Check Armstrong Number
A number is called as Armstrong number if sum of cubes of digits of number is equal to the number itself. In this program we will check whether a number is Armstrong or not.
- // C program to check Armstrong number
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int numb, originalNumb, r, result = 0, n = 0 ;
- printf("Enter an integer: ");
- scanf("%d", &numb);
- originalNumb = numb;
-
- while (originalNumb != 0)
- {
- originalNumb /= 10;
- ++n;
- }
- originalNumb = numb;
- while (originalNumb != 0)
- {
- r = originalNumb%10;
- result += pow(r, n);
- originalNumb /= 10;
- }
- if(result == numb)
- printf("%d is an Armstrong number.", numb);
- else
- printf("%d is not an Armstrong number.", numb);
- return 0;
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App