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


Please Help Members By Posting Answers For Below Questions

What is a class template in c++?

770


Why Pointers are not used in C++?

800


What is a far pointer? where we use it?

803


Should a constructor be public or private?

745


Which ide is best for c++?

753


What is stoi in c++?

909


Explain rtti.

783


What is exception handling? Does c++ support exception handling?

784


How can we access protected and private members of a class?

824


what are Access specifiers in C++ class? What are the types?

839


What is protected inheritance?

797


What is vector string in c++?

793


What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

832


What is a lambda function c++?

774


What does the nocreate and noreplace flag ensure when they are used for opening a file?

879