## 23.11.14

### OOP : Excercise-10 : Check palindrome. Use Inheritance

Check whether the given number is palindrome or not. Use individual/separate member function to take input, output and display according to logic. Use Inheritance

1. #include
using namespace std;
class pc
{
public:
void setget(int n)
{
get=n;
}
protected:
int get;
};
class number:public pc
{
public:
int n1,rev=0,rem,n;
int devide()
{
n1=n;
while(n>0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
}
int check()
{
if(n1==rev)
cout<<"palindrome number";
else
cout<<"not palindrome number";
}
};
int main()
{
number nb;
int a;
cin>>a;
nb.setget(a);
nb.check();
};

1. noted and found correct

2. #include
using namespace std;
class palindrome
{
public:
void setinput(int n)
{
num=n;
}
protected:
int num;
};
class number:public palindrome
{
public:
int i,t,rev=0;
int devide()
{
t=num;
while(t!=0)
{
i=t%10;
rev=rev*10+i;
t/=10;
}
}

int check()
{
if(num==rev)
cout<<"palindrome";
else
cout<<"not palindrome";
}
};
int main()
{
number nmb;
int a;
cin>>a;
nmb.setinput(a);
nmb.devide();
nmb.check();
}

3. This comment has been removed by the author.

4. #include
using namespace std;
class palindrom
{
protected:
int digit;

public:
void setdigit(int n)
{
digit=n;
}

};
class chkpalindrom : public palindrom
{
public:
int a,b,c,sum=0,n;

int calc()
{
a=n%10;
b=n%100;
b=b/10;
c=n/100;
sum=a*100+b*10+c;

}
int check()
{

if(sum==n)
cout<<"\nIt is a pelindrom number\n\n";
else
cout<<"\nIt is not a pelindrom number\n\n";
}
};
int main()
{
chkpalindrom cp;
int n;
cin>>n;
cp.setdigit(n);
cp.check();
}

5. Name-Main Uddin
ID-201421090
Batch-46

#include
using namespace std;
class AUB
{
public:
void IN(int F)
{
IO=F;
}
protected:
int IO;
};
class DIP:public AUB
{
public:
int iX,tNum,SetR;
int LDmain()
{
tNum=IO;
int SetR=0;
while(tNum!=0)
{
iX=tNum%10;
SetR=SetR*10+iX;
tNum/=10;
}
return SetR;
}

int check()
{
SetR=LDmain() ;
if(IO==SetR)
cout<<"palindrome Number";
else
cout<<"not palindrome Number";
}
};
int main()
{
DIP Dnum;
int Y;
cout<<"Enter The Number ";
cin>>Y;
Dnum.IN(Y);
Dnum.LDmain();
Dnum.check();
}

http://itlearn24.blogspot.com/2014/11/check-whether-given-number-is_29.html

7. nazmul alam
201420674
46th
//C++ program : To check whether a given number is palindrome or not
#include
using namespace std;
int main()
{
int n, num, digit, rev = 0;
cout << "Enter a positive number: ";
cin >> num;
n = num;
do
{
digit = num%10;
rev = (rev*10) + digit;
num = num/10;
}while (num!=0);
cout << " The reverse of the number is: " << rev << endl;
if (n = = rev)
cout << " The number is a palindrome";
else
cout << " The number is not a palindrome";

system("pause");
return 0;
}

CSE-46(Dip)
ID=201420656

#include
using namespace std;
class palindrome
{
public:
void setvalue(int v)
{
value=v;
}
protected:
int value;
};
class value:public palindrome
{
public:
int i,t,rev=0;
int devide()
{
t=value;
while(t!=0)
{
i=t%10;
rev=rev*10+i;
t/=10;
}
}

int check()
{
if(value==rev)
cout<<"palindrome";
else
cout<<"not palindrome";
}
};
int main()
{
value v;
int x;
cin>>x;
v.setinput(x);
v.devide();
v.check();
}

9. #include
#include
using namespace std;

class Circle {
private:
string color;

public:
Circle(double r = 1.0, string c = "red") {
color = c;
}

{
}

string getColor()
{
return color;
}

double getArea()
{
}
};

int main() {
Circle c1(1.2, "blue");
<< " Color=" << c1.getColor() << endl;

Circle c2(3.4);
<< " Color=" << c2.getColor() << endl;

Circle c3;
<< " Color=" << c3.getColor() << endl;
return 0;
}

10. Md. Zulfikar Ali
45th Batch
201410524

#include
#include
using namespace std;

class Circle {
private:
string color;

public:
Circle(double r = 1.0, string c = "red") {
color = c;
}

{
}

string getColor()
{
return color;
}

double getArea()
{
}
};

int main() {
Circle c1(1.2, "blue");
<< " Color=" << c1.getColor() << endl;

Circle c2(3.4);
<< " Color=" << c2.getColor() << endl;

Circle c3;
<< " Color=" << c3.getColor() << endl;
return 0;
}

11. #include
#include
using namespace std;

class Circle {
private:
string color;

public:
Circle(double r = 1.0, string c = "red") {
color = c;
}

{
}

string getColor()
{
return color;
}

double getArea()
{
}
};

int main() {
Circle c1(1.2, "blue");
<< " Color=" << c1.getColor() << endl;

Circle c2(3.4);
<< " Color=" << c2.getColor() << endl;

Circle c3;
<< " Color=" << c3.getColor() << endl;
return 0;
}

12. md kashem
roll-201410856

#include
using namespace std;
class palindrome
{
public:
void setinput(int a)
{
num=a;
}
protected:
int num;
};
class number:public palindrome
{
public:
int i,r,rev=0;
int devide()
{
r=num;
while(r!=0)
{
i=r%10;
rev=rev*10+i;
r/=10;
}
}

int check()
{
if(num==rev)
cout<<"It is palindrome";
else
cout<<"It is not palindrome";
}
};
int main()
{
number nmb;
int s;
cin>>s;
nmb.setinput(s);
nmb.devide();
nmb.check();
}

13. md kashem
roll-201410856

#include
using namespace std;
class palindrome
{
public:
void setinput(int a)
{
num=a;
}
protected:
int num;
};
class number:public palindrome
{
public:
int i,r,rev=0;
int devide()
{
r=num;
while(r!=0)
{
i=r%10;
rev=rev*10+i;
r/=10;
}
}

int check()
{
if(num==rev)
cout<<"It is palindrome";
else
cout<<"It is not palindrome";
}
};
int main()
{
number nmb;
int s;
cin>>s;
nmb.setinput(s);
nmb.devide();
nmb.check();
}

Comment Here