RECENTLY PUBLISHED

6/recent/ticker-posts

C++ Program to check whether entered number is Armstrong or not.


IS ARMSTRONG OR NOT   



#include<iostream>


using namespace std;


int main()



int i, sum=0, num1,num2, r;


cout<<"Enter a number: "; 


cin>>num1;


num2=num1; 


while(num1>0)



r=num1%10;


 sum=sum+r*r*r;


 num1=num1/10;


}


 if(num2==sum)


{


 cout<<"\n %d is Armstrong number:";


 }


else


{


 cout<<"\n %d is not Armstrong number:";


}


return 0;


}




INPUT && OUTPUT





With this code we can check whether entered number is Armstrong or not!!

Post a Comment

0 Comments