Write a C program to check whether a number is a Strong Number or not using the Virtual base Class in Object Oriented Programming(OOP).

#include<iostream>
using namespace std;
class Grand_FatherT4Tutorials
{
public :
int ip;
};
class p1:virtual public Grand_FatherT4Tutorials
{
public :
int sum;
};
class p2:virtual public Grand_FatherT4Tutorials
{
public :
int save;
};
class derived:public p1,public p2
{
protected :
int fact,num;
public :
s_num();
};
derived::s_num()
{
sum=0;
cout<<"Enter number to check: ";
cin>>ip;
save=ip;
while(ip)
{
num=ip%10;
fact = 1;
for(int i=num;i>0;i--)
{
fact=fact*i;
}
sum+=fact;
ip/=10;
}
if(sum==save)
{
cout<<save<<" is a Strong Number";
}
else
{
cout<<save<<" is not a Strong Number";
}
}
int main()
{
derived a;
a.s_num();
}
Some FAQ
1 is a strong number or not? 1 is a strong number.
2 is a strong number or not? 2 is a strong number.
3 is a strong number or not? 3 is not a strong number.
4 is a strong number or not? 4 is not a strong number.
5 is a strong number or not? 5 is not a strong number.
6 is a strong number or not? 6 is not a strong number.
7 is a strong number or not? 7 is not a strong number.
8 is a strong number or not? 8 is not a strong number.
9 is a strong number or not? 9 is not a strong number.