C Programming Tutorial

Advertisements

Write program to check whether a number is Palindrome or not in c



       #include<stdio.h>
       #include<conio.h>
       void main()
       {
              int a,n,num,rev=0; 
              clrscr();

              printf("\nEnter any number : "); 
              scanf("%d",&num); 
              
              n = num;

              while(num>0)
              {
                   m = num % 10;
                   rev = (rev*10) + m;
                   num = num / 10;
                }
              
              if(n == rev)
                   printf("\nYes! given number is Palindrome.");
              else
                   printf("\nNo! given number is not Palindrome.");

              getch();
       }

   Output : 

              Enter any number : 15251
              Yes! given number is Palindrome.




Advertisement