write program for palindrome
Answer Posted / purnachandra sahoo
/*Program to check whether a number is palindrom or not*/
#include<iostream.h>
#include<conio.h>
int pall(int);
void main()
{
int n,res;
clrscr();
cout<<"Enter the number :";
cin>>n;
res=pall(n);
cout<<" which is:"<<res;
getch();
}
int pall(int x)
{
int p,a,sum=0;
p=x;
while(x!=0)
{
a=x%10;
sum=sum*10+a;
x=x/10;
}
if(sum==p)
{
cout<<"\nThe enterd number is palindrom" ;
return(sum);
}
else
{
cout<<"\nThe entered number is not palindrom" ;
return 0;
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are the extraction and insertion operators in c++? Explain with examples.
What are the 4 types of library?
Write a program to concatenate two strings.
Array base access faster or pointer base access is faster?
Which is the best c++ compiler?
Explain what you mean by a pointer.
Can I uninstall microsoft c++ redistributable?
Define linked lists with the help of an example.
Why do we use classes in programming?
Why do we use pointers in c++?
Explain the difference between c++ and java.
Is c or c++ more useful?
Which is the best c++ compiler for beginners?
Explain differences between new() and delete()?
Do class declarations end with a semicolon?