Sunday, December 6, 2009
Armstrong number
,
Author: Raviteja
|
Filed Under:
c++
|
#include "iostream.h"
#include "conio.h"
class one
{
protected:
int n,q,r,N;
public:
one ()
{
N = 0;
}
void cal ();
};
class two : public one
{
public:
void accept ()
{
cout << "Welcome to find Armstrong Number\n\n";
cout << "Enter a number: ";
cin >> n;
}
};
void one :: cal ()
{
int x = n;
for (; q>0; )
{
q = n / 10;
r = n % 10;
N += (r * r * r);
n = q;
}
if (N == x)
cout << "\nThe number is an Armstrong Number";
else
cout << "\nThe number is not an Armstrong Number";
}
void main ()
{
clrscr ();
two T;
T.accept ();
T.cal ();
getch ();
}
Get the executable ( .exe ) file for this program..
Download
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment