Friday, August 16, 2019

WAP to check whether the given number is palindrome or not.

// Program

#include<stdio.h>
void main()
{
     int a,n,r,d;
     r=0;
     clrscr();
     printf("Enter any number:");
     scanf("%d",&n);
     while(n)
     {
          a=n;
          while(a>0)
          {
               d=a%10;
               r=(r*10)+d;
               a=a/10;
           }
      if(r==n)
           printf("The number is palindrome");
     else
           printf("The number is not palindrome");
     }
     getch();
}

Sample Input/Output:

Enter any number:1221
The number is palindrome

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...