C program to check whether given number is palindrome or not.

C Program to check whether given number is Palindrome or not.

 

Palindrome:-  An Palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers.


Let’s write a program.

 

Step 1:- Let’s open Turbo C and write the following code.

 

//Add preprocessor

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

 

// Declare vaiable

char a[25],b[25],i,j;

 

// Clear screen

clrscr();

 

printf(“enter any string : \n ”);

gets(a);

strcpy(b,a);

strrev(b);

if(strcmp(a,b)==0)

{

printf(“this is a Palindrome”);

}

else

{

printf(“this is not a palindrome”);

}

getch();

}

 

 

Step 2:- Now save it by pressing F2 and name it PALINDROME.CPP.

 

 

 

Step 3:- After save it compile it by pressing ALT+F9 to check errors and correct them.

 

 

 

Step 4:- Now run the program by click on RUN or by pressing ALT+R and see output.

 

 

Ouput:

 

 

palindrom

 

Happy  coding.

 

 

 

 

 

Tags: , , ,