0

Write a program that print armstrong number upto 1000

3rd Dec 2016, 9:31 AM
Aman Singh
Aman Singh - avatar
2 Respostas
+ 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; }
3rd Dec 2016, 12:17 PM
Jobelle
Jobelle - avatar
+ 1
what is a armstrong number actually😅
18th May 2017, 12:48 PM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar