Q:

write a C program to check whether a number is palindrom or Not

0

write a C program to check whether a number is palindrom or Not

----------------------------------------------------------------------------------------------------------------

 

Palindrome number in c: A palindrome number is a number that is same after reverse. For example 121, 34543, 343, 131, 48984 are the palindrome numbers.

Palindrome number algorithm

  1. Get the number from user
  2. Hold the number in temporary variable
  3. Reverse the number
  4. Compare the temporary number with reversed number
  5. If both numbers are same, print palindrome number
  6. Else print not palindrome number

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>  
int main()    
{    
int n,r,sum=0,temp;    
printf("enter the number=");    
scanf("%d",&n);    
temp=n;    
while(n>0)    
{    
r=n%10;    
sum=(sum*10)+r;    
n=n/10;    
}    
if(temp==sum)    
printf("palindrome number ");    
else    
printf("not palindrome");   
return 0;  
}   

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now