ARMSTRONG NO

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();

int num;
int digit;
int sum;

cout<<“Armstrong numbers between 1-500\n\n”;

for(int j=1;j<=500;j++)
{
num=j;
sum=0;
while(num)
{
digit=num%10;
sum+=digit*digit*digit;
num=num/10;
}

if(sum==j)
cout<<j<<” “;
}
getch();
}

Advertisements

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