8. Write a program to find whether the number is Armstrong number.

 SOURCE CODE:


include <stdio.h>

int main()
{   int num,rem,res=0,real_num;

    printf("enter a number\n");
    scanf("%d",&num);

    real_num=num;
    while(real_num!=0){
    rem=real_num%10;
    res+=rem*rem*rem;
    real_num/=10;
    }
     if(num==res)
     { printf("%d is an armstrong number",num); }
     else
     printf("%d is not an armstrong number",num);

    return 0;
}


Comments