C Programming Code Examples C > Mathematics Code Examples Program to check Armstrong number 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 the below C program, we are checking whether the input number is Armstrong or not. #include<stdio.h> int main() { int num,copyofnum,sum=0,rem; //Store input number in variable num printf("\nEnter a number:"); scanf("%d",&num); /* Value of variable num would change in the below while loop so we are storing it in another variable to compare the results at the end of program*/ copyofnum = num; /* We are adding cubes of every digit and storing the sum in variable sum */ while (num != 0) { rem = num % 10; sum = sum + (rem*rem*rem); num = num / 10; } /* If sum of cubes of every digit is equal to number * itself then the number is Armstrong */ if(copyofnum == sum) printf("\n%d is an Armstrong Number",copyofnum); else printf("\n%d is not an Armstrong Number",copyofnum); return(0); }