Q.WAP to check whether given string is palindrone
or not.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,l=0;
cout<<"Enter a number";
cin>>i;
j=i;
do
{
k=i%10;
l=k+l*10;
i=i/10;
}while(i>0);
cout<<endl<<"Reversed no. is"<<l;
if(j==l)
cout<<endl<<"Palindrone";
else
cout<<endl<<"Not a Palindrone";
getch();
}
or not.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,l=0;
cout<<"Enter a number";
cin>>i;
j=i;
do
{
k=i%10;
l=k+l*10;
i=i/10;
}while(i>0);
cout<<endl<<"Reversed no. is"<<l;
if(j==l)
cout<<endl<<"Palindrone";
else
cout<<endl<<"Not a Palindrone";
getch();
}
No comments:
Post a Comment