write program for palindrome
Answer Posted / gaurav joshi
#include <stdio.h>
int main()
{
int number,temp,remainder,sum=0;
printf("nnEnter no: ");
scanf("%d",&number);
temp = number; //Value of temp stores unmodified n value
while(number>0)
{
remainder=number%10;
number/=10;
sum=sum*10 + remainder; //Builds value of reversed number
}
if (sum==temp)
printf ("nThe Number Is A Palindrome ");
else
printf ("nThe Number Is Not A Palindrome ");
getch ();
return 0;
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Why cstdlib is used in c++?
Differences between private, protected and public and give examples.
Which function should be used to free the memory allocated by calloc()?
If there are two catch statements, one for base and one for derived, which should come first?
In c++, what is the difference between method overloading and method overriding?
What can c++ be used for?
What is scope in c++ with example?
What is iterator c++?
What does obj stand for?
What is the hardest coding language to learn?
How a new operator differs from the operator new?
What is the type of 'this' pointer? When does it get created?
Can a function take variable length arguments, if yes, how?
Which operator cannot be overloaded c++?
What are the comments in c++?