Sunday, March 17, 2013

C++ program to find Armstrong number

10:15 AM

C++ Program to Check given number is Armstrong number or not


#include<iostream>
#include<iomanip>
int main(){
    int num,r,sum,temp;
    for(num=1;num<=500;num++){
         temp=num;
         sum = 0;
         while(temp!=0){
             r=temp%10;
             temp=temp/10;
             sum=sum+(r*r*r);
         }
         if(sum==num)
             cout << num << setw(2);
    }
    return 0;
}

 

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top