Step 1: Start
Step 2: Declare integers n, t, t1, sum, sum1, count, digit
Step 3: Take input for number (n)
Step 4: Count the number of digits
Step 5: Compute sum of digits raised to power count
Step 6: Check if sum equals original number
Step 7: Print whether it is an Armstrong number or not
Step 8: End
#include<stdio.h> #include<math.h> int main() { int n, t, t1, sum = 0, sum1 = 0, count = 0, digit; printf("Enter a number :"); scanf("%d", &n); t = n; t1 = n; while(n != 0) { digit = n % 10; sum = sum + digit; n = n / 10; count++; } sum1 = 0; while(t != 0) { digit = t % 10; sum1 = sum1 + pow(digit, count); t = t / 10; } printf("\n Number of digits in %d : %d", t1, count); printf("\n Sum of the digits of %d : %d", t1, sum); if(sum1 == t1) { printf("\n %d is an Armstrong Number", t1); } else { printf("\n %d is Not an Armstrong Number", t1); } return 0; }
Enter a number: 153 Number of digits in 153: 3 Sum of the digits of 153: 9 153 is an Armstrong Number