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 is the c++ code?
Carry out conversion of one object of user-defined type to another?
What is a null object in c++?
what are the decision making statements in C++? Explain if statement with an example?
What is the best it certification?
What is searching?
Explain the difference between class and struct in c++?
What is data structure in c++?
Write a C++ Program to check whether a number is prime number or not?
What is #include ctype h in c++?
Where are setjmp and longjmp used in c++?
Explain overriding.
What is the use of namespace std in C++?
What are the various operations performed on stack?
What return value must conversion operators have in their declaration?