C Program To Find The Number Palindrome or Not
/* To Find Whether Number is Palindrome or Not */
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include<stdio.h> //#include<conio.h> void main() { int num,rem,sum=0,temp; //clrscr(); printf("\n /** To Find Reverse Of a Number **/ \n"); printf("\n Enter a number: "); scanf("%d",&num); temp=num; while(num) { //for getting remainder by dividing with 10 rem=num%10; //for getting quotient by dividing with 10 num=num/10; //multiplying the sum with 10 and adding remainder sum=sum*10+rem; } printf("\n The Reversed Number is: %d \n",sum); //checking whether the reversed number is equal to entered number if(temp==sum) { printf("\n Number is Palindrome \n\n"); } else { printf("\n Number is not a palindrome \n\n"); } //getch(); return 0; } |
Sample Output:( using GNU GCC Compiler with code::blocks IDE, hence no need of clrscr(); and getch(); )