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


Please Help Members By Posting Answers For Below Questions

Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

611


What are iterators in c++?

589


Explain the properties and principles of oop.

526


Explain how would you handle a situation where you cannot call the destructor of a local explicitly?

535


What is a vector c++?

547






What are the types of pointer?

544


What is the difference between equal to (==) and assignment operator (=)?

575


What does it mean to declare a member variable as static?

608


What is a try block?

634


Is c++ a programming language?

590


What is the use of ::(scope resolution operator)?

644


What are c++ templates used for?

613


Can a Structure contain a Pointer to itself?

606


How do we implement inheritance in c++?

582


What is c++ used for in games?

600