answersLogoWhite

0


Best Answer

unsigned reverse (unsigned n) {

unsigned r = 0;

while (n) {

r *= 10;

r += (n%10);

n /= 10;

}

return r;

}

bool is_palindrome (unsigned n) {

return n == reverse (n);

}

int main () {

unsigned num;

printf ("Enter a number: ");

scanf ("%d", num);

if (is_palindrome (num))

printf ("%d is a palindrome\n");

else

printf ("%d is not a palindrome\n");

return 0;

}

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a simple program in c to check whether a number is a palindrome or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program using method plainto check whether a string is a palindrome or not A palindrome is a string that reads the same from left to right and vice-versa?

Palindrome number is a number like 121 which remains the same when its digits are reversed. To find this number in a simple java program, just follow the below way. sum = 0; while(n>0) { r=n % 10; sum=concat(r); n=n / 10; } print r;


How do you write a program in C to check whether a word is a palindrome or not?

It is a simple program. i think u may understand it :#include#include#includevoid main(){char s[10]=answers.com;char x[10];int a;clrscr();strcpy(x,s);strrev(s);a=strcmp(s,x);if(a==0){printf("the entered string is palindrome");}else{printf("the entered string is not palindrome");}output:given string is not palindrome


Find the largest palindrome made from the product of two 3-digit numbers?

906609=913*993 I found this using a relatively simple computer program that I wrote.


You want to write a simple without using pointer or array c program which will print greatest number when you give 20 number?

i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?


How do you calculate sum of digit of a given three digit number in visual basic?

simple program


What is the missing number 111214 2126?

There is no simple answer because the position of the missing number is not known. Furthermore, it is not clear whether the sequence is an arithmetic, geometric or some other sequence.


Write a C program to find out whether character passes through keybroad is a digit or not?

hey..it s simple..make use of built-in function isdigit(character)..it s in stdlib.h...


What is an example of a simple employee assistance program?

Some EAPs are just a hotline. Employees are encouraged to call a particular number and ask for help.


How do you disconnect the vcr in a samsung television model number CXD1334?

Disconnecting a VCR from a Samsung TV is simple. All you have to do is download the uninstall program.


How do you calculate number of prime number between 1 and 1000?

There is no simple way since there is no known pattern for the exact distribution of primes. You just have to go and check each number to see whether or not it is a prime.


How do you loop a program in python 3?

A program can be looped in Python by wrapping the entire program in a for or while loop. If you wish to loop the program a finite amount of times, it can be done like so (x = the amount of times you want it to loop, this can be a number or variable storing a number): for i in range(0,x): [code] If you wish to loop the program infinitely, you can use a simple while loop: while True: [code]


Simple c language program?

Well, this is a very open question, please be specific, I will try try to answer this as well, a simple c language program can be any thing from printing your name on the screen to printing some patterns using symbols, or making a small game, or a simple calculator program. you can a clearer picture of what can be a simple c language program here: