C program to check the given number is armstrong number or not



#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;
}

Output:

C programs, c programming, c examples, armstrong number in c

07 Aug 2015

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top