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 is a class template in c++?
Why Pointers are not used in C++?
What is a far pointer? where we use it?
Should a constructor be public or private?
Which ide is best for c++?
What is stoi in c++?
Explain rtti.
What is exception handling? Does c++ support exception handling?
How can we access protected and private members of a class?
what are Access specifiers in C++ class? What are the types?
What is protected inheritance?
What is vector string in c++?
What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
What is a lambda function c++?
What does the nocreate and noreplace flag ensure when they are used for opening a file?