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
What are the 4 types of library?
What do you mean by stack unwinding in c++?
What information can an exception contain?
How do you clear a buffer in c++?
Can member functions be private?
What are the implicit member functions of class?
How can we access protected and private members of a class?
Does a derived class inherit or doesn't inherit?
What is lazy initialization in c++?
What is a pointer with example?
an integer constant must have atleast one a) character b) digit c) decimal point
What is c++ namespace?
What is exception handling? Does c++ support exception handling?
What are mutator methods in c++?
Is c the same as c++?