Write a program to input a no. and check whether it is palindrome or not.

                                                                 

Write a program to input a no. and check whether it is palindrome or not.

Code Written in Dev C++;

#include<stdio.h>

#include<conio.h>

int main()

{

int n, n1, a, r=0;

printf("\nEnter any no.:-");

scanf("%d",&n);

n1 = n;

while(n>0)

{

a = n % 10;

r = r * 10 + a;

n = n/10;

}

if(n1==r)

{

printf("\n Enter number is palindrome.");

}

else

{

printf("\n Enter number is not palindrome.");

}

return 0;

}

Code Written in Turbo C++ :-

#include<stdio.h>

#include<conio.h>

void main()

{

int n, n1, a, r=0;

clrscr();

printf("\nEnter any no.:-");

scanf("%d",&n);

n1 = n;

while(n>0)

{

a = n % 10;

r = r * 10 + a;

n = n/10;

}

if(n1==r)

{

printf("\n Enter number is palindrome.");

}

else

{

printf("\n Enter number is not palindrome.");

}

getch();

}

Post a Comment

0 Comments