**New course!**Every coder should learn

**Generative AI!**

0

# Write a program that print armstrong number upto 1000

2 Answers

+ 26

#include < iostream.h >
int main()
{
int r;
long number = 0, c, sum = 0, temp;
cout<<"Enter an integer upto which you want to find armstrong numbers\n";
cin>>number;
cout<<"Following armstrong numbers are found from 1 to"<<number<<"\n";
/*if sum of cubes of each digit in a number is same as the number then it is called as armstrong no.*/
for( c = 1 ; c < = number ; c++ )
{
temp = c;
while( temp != 0 )
{
r = temp%10;
sum = sum + r*r*r;
temp = temp/10;
/*taking unit place digits cube and adding into sum*/
}
if ( c == sum )
cout<<c<<"\n";
sum = 0;
}
return 0;
}

+ 1

what is a armstrong number actually😅