Saturday, August 9, 2014

Program to check whether a number is a palindrome.

Program to find if a number is a palindrome. One of the most basic programs for any CSE student to learn. Comment below if you need help

#include<stdio.h>
void main()
{
int x,num,sum=0,rem;
printf("enter the number");
scanf("%d",&num);
x=num;
while(num>0)
{
rem=num%10;
sum=(sum*10)+rem;
num=num/10;
}
if(sum==x)
printf("palindrome");
else
printf("no");
}

No comments:

Post a Comment