Note: Armstrong numbers are those numbers if we take cube of their digits individually and add them then it will equal to the number.
e.g: 153
1^3 + 5^3 + 3^3 = 153
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int remainder, temp, sum=0, num, i;
for(i=1; i<=1000; i++)
{
num = temp = i;
sum = 0;
while(temp != 0)
{
remainder = temp%10;
sum = sum + remainder*remainder*remainder;
temp = temp/10;
}
if(num == sum)
cout <<sum<<endl;
}
getch();
}
e.g: 153
1^3 + 5^3 + 3^3 = 153
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int remainder, temp, sum=0, num, i;
for(i=1; i<=1000; i++)
{
num = temp = i;
sum = 0;
while(temp != 0)
{
remainder = temp%10;
sum = sum + remainder*remainder*remainder;
temp = temp/10;
}
if(num == sum)
cout <<sum<<endl;
}
getch();
}