write program for palindrome
Answer Posted / prashant gupta
//in C Language
#include <stdio.h>
#include <conio.h>
int main()
{
int number,temp,remainder,sum=0;
printf("\n\nEnter no: ");
scanf("%d",&number);
temp = number; //Value of temp stores unmodified n value
while(number>0)
{
remainder=number%10; //Gets Last Digit
number/=10; //Truncates Last Digit
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 ? | 1 Yes | 0 No |
Post New Answer View All Answers
How do I use arrays in c++?
What is stack unwinding?
What is this weird colon-member (" : ") syntax in the constructor?
What is the use of c++ programming language in real life?
What kind of problems can be solved by a namespace?
How do you compile the source code with your compiler?
How does list r; differs from list r();?
Differentiate between an inspector and a mutator ?
How do you add an element to a set in c++?
Is map sorted c++?
What is extern c++?
What is setf in c++?
When can I use a forward declaration?
What is binary object model?
Which ide is best for c++?