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
Why is c++ awesome?
What is one dimensional array in c++?
What is setfill c++?
What is pointer with example?
Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work
Why do we use double in c++?
How a modifier is similar to mutator?
What are c++ data types?
Differences between private, protected and public and give examples.
What is new in c++?
What is the use of typedef?
Why are arrays usually processed with for loop?
Distinguish between a # include and #define.
Does c++ have string data type?
List different attributes in C++?