//Program to find reverse of IP number and compare them
#include<iostream>
using namespace std;
class number
{
int i,j,x=0;
int n, t[5], rev_array[5];
public:
void in()
{
cout<<"Enter any five digit number: ";
cin>>n;
}
void rev()
{
int r,temp;
i=0;
temp=n;
while(n!=0)
{
r=n%10;
n=n/10;
t[i]=r;
i++;
}
n=temp;
j=4;
for(i=0;i<5;i++)
{
rev_array[j]=t[i];
j--;
}
cout<<"Reverse of the IP number is: ";
for(i=0;i<=4;i++)
{
cout<<t[i];
}
}
int compare()
{
int x;
for(i=0;i<5;i++)
{
if(t[i]==rev_array[i])
{
x=1;
return(x);
}
else
{
x=0;
return(x);
}
}
}
void result()
{
int z;
z=compare();
cout<<endl<<endl;
if(z==1)
{
cout<<n<<" and its reverse are similar";
}
else
{
cout<<n<<" and its reverse are not similar";
}
}
};
int main(void)
{
number num;
num.in();
num.rev();
num.result();
}
No comments:
Post a Comment
Comments please: