Check the Number is Amstrong or Not


Source Code

//amstrong number
#include
#include
class amstr
{
int x,copy,y,z;
public:
amstr()
{
x=copy=y=z=0;
}
void read()
{
cout<>x;
}
void arm()
{
copy=x;
while(x>0)
{
y=x%10;
x=x/10;
z=z+(y*y*y);
}
if(z==copy)
{
cout<<"the no is amstrong";
}
else
{
cout<<"the no is not amstrong";
}
}
};
void main()
{
clrscr();
amstr obj;
obj.read();
obj.arm();
getch();
}

Click Here! to download this file

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