Armstrong number

Print Armstrong number.

C++:
01 void printArmstrong()
02 {
03     for(int i=0;i<=9;i++){
04         for(int j=0;j<=9;j++){
05             for(int k=0;k<=9;k++){
06                 int num=100*i+10*j+k;
07                 int qsum=i*i*i+j*j*j+k*k*k;
08                 if(num==qsum)
09                     cout<<num<<endl;
10             }
11         }
12     }
13     cout<<endl;
14 }
Advertisements
This entry was posted in Array and linked list. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s