Choose Category
//TO FIND AMSTRONG NUMBERS WITHIN THE GIVEN RANGE #include<iostream.h> #include<conio.h> class Amstrong { long num,res,c,a; int rem; public: void check_ams(int num) { cout<<"\nFollowing amstrong numbers are found from 1 to "<<num; for(c=1 ;c<=num; c++) { res=0; a=c; while( a!= 0 ) { rem = a%10; res = res + rem*rem*rem; a = a/10; } if( c==res ) cout<<"\n"<<c; res=0; } } }; void main() { Amstrong am; int num; clrscr(); cout<<"Enter the maximum range upto which u want to find amstrong numbers:"; cin>>num; am.check_ams(num); getch(); }