#include<iostream>
using namespace std;
class perfect
{
public:
void setelement(int value)
{
element =value;
}
protected: int element;
};
class chkelement: public perfect
{
public:
int sum=0;
void getperfect()
{
for(int i=1;i<element;i++)
{
if(element%i==0)
{
sum+=i;
}
}
}
int chksum()
{
if (element==sum)
cout<<"Yes!!"<<endl<<"the element is perfect number"<<endl<<endl;
else
cout<<"Not!!"<<endl<<"the element is not a perfect number"<<endl;
}
};
int main()
{
chknelement per;
int value;
cout<<"the element to check perfect or not : ";
cin>>value;
per.setelement(value);
per.getperfect();
per.chksum();
return 0;
}
using namespace std;
class perfect
{
public:
void setelement(int value)
{
element =value;
}
protected: int element;
};
class chkelement: public perfect
{
public:
int sum=0;
void getperfect()
{
for(int i=1;i<element;i++)
{
if(element%i==0)
{
sum+=i;
}
}
}
int chksum()
{
if (element==sum)
cout<<"Yes!!"<<endl<<"the element is perfect number"<<endl<<endl;
else
cout<<"Not!!"<<endl<<"the element is not a perfect number"<<endl;
}
};
int main()
{
chknelement per;
int value;
cout<<"the element to check perfect or not : ";
cin>>value;
per.setelement(value);
per.getperfect();
per.chksum();
return 0;
}