C program to find whether a given number is an Armstrong number or not

Here is the C program to find whether a given number is an Armstrong number or not

				
					#include <stdio.h>

int main() {
  int n, r, sum = 0, temp;

  printf("Enter a number: ");
  scanf("%d", & n);

  temp = n;

  while (n > 0) {
    r = n % 10;
    sum = sum + r * r * r;
    n = n / 10;
  }

  if (sum == temp) {
    printf("%d is an Armstrong number.\n", temp);
  } else {
    printf("%d is not an Armstrong number.\n", temp);
  }

  return 0;
}
				
			
Output
C Program to Check Armstrong Number