Wednesday, 7 October 2015

Write a CPP Program To Check Number is Armstrong or Not

Write a CPP Program To Check Number is Armstrong or Not
1:  #include<iostream.h>  
2:  #include<stdio.h>  
3:  int main()  
4:  {  
5:    int num,rem,c,result=0;  
6:    cout<< "Enter number" <<endl;  
7:    cin>>num;  
8:    c=num;  
9:    do  
10:    {  
11:      rem=num%10;  
12:      result=result+(rem*rem*rem);  
13:      num=num/10;  
14:    }  
15:    while(num>0);  
16:    if(result==c)  
17:      cout<< "Armstrong"<<endl;  
18:    else  
19:      cout<< "Not armstrong"<<endl;  
20:  }  

No comments:

Post a Comment