#include <iostream>
using namespace std;
class Reverse
{
int n,num,dig,rev;
public:
void Rev()
{
cout<<"enter an integer number to check if it palindrome or not \t";
cin>>num;
n=num; //
rev=0;
while(num>0)
{
dig=num%10; // 48%10=4
rev= rev*10+dig; // rev=48*10+4=484
num=num/10; //484/10 =48
cout<<num;
}
if (n==rev)
cout<<"given number is palindrome";
else
cout<<"given number is not palindrome";
}
};
int main()
{
Reverse P;
P.Rev();
return 0;
}
dig=num%10; // 48%10=4
rev= rev*10+dig; // rev=48*10+4=484
num=num/10; //484/10 =48
im not getting the logic here, if rev=0 is assigned, then wouldn't rev= rev*10+dig be equal to dig? :icon_frown: