Thursday 25 February 2016

Check the given number is palindrome number or not using c program

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

No comments:

Post a Comment