Palindrome number

Program:

#include<stdio.h>
int main()
{
int n,rev=0,rem,temp;
printf("Enter number: ");
scanf("%d",&n);
temp=n;
while(n>0)
{
rem=n%10; //separate the digit
rev=(rev*10)+rem; //reverse of number
n=n/10;
}
if(temp==rev)
{
printf("Palindrome number");
}
else
{
printf("Not a Palindrome number");
}
return 0;
}

Output:




No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...