Hello Devs,

In this tutorial, we are going to learn C program to check whether a number is Armstrong or not. Those numbers which sum of the cube of its digits is equal to that number are known as Armstrong numbers.

Here is a well-commented example you can understand and analyze.\

# include <stdio.h>
int main(){
    int num,r,sum=0,temp;

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

    temp=num;
    while(num!=0){
         r=num%10;
         num=num/10;
         sum=sum+(r*r*r);
    }
    if(sum==temp)
         printf("%d is an Armstrong number",temp);
    else
         printf("%d is not an Armstrong number",temp);

    return 0;
}


I hope this example helps you.