#include<iostream.h>
#include<string.h>
#include<conio.h>
void palin(int);
void palin(char []);
void main()
{
int num;
char a[20];
clrscr();
cout<<"\n Function overloading using palindrome";
cout<<"\n Enter the String";
cin>>a;
palin(a);
cout<<"\n Enter the Number";
cin>>num;
palin(num);
getch();
}
void palin(char a[])
{
int i,j,l;
l=strlen(a)-1;
for(i=0,j=l;i<l/2;)
{
if(a[i]!=a[j])
{
cout<<"\n String is not a palindrome";break;
}
else
{
i++;
j--;
}
}
if(i==l/2)
{
cout<<"\n Given String is Palindrome";
}
}
void palin(int num)
{
int n=num,rem,rev=0;
while(n>0)
{
rem=n%10;
rev=(rev*10)+rem;
n=n/10;
}
if(num==rev)
cout<<"\n number is a palindrome";
else
cout<<"\n Not a palindrome";
}
Comments
Post a Comment