Ad Code

NEW POST

6/recent/ticker-posts

STRING PALINDROME USING STRREV(); STRCMP();

...

CONCEPT:

cp=checking palindrome

rcp= reverse checking palindrome

using strcpy copy co to rcp and then reverse it using strrev() and check in IF() condition if condition is true ==1 and for false condition ==0;,

can be used for numbers and characters both.


 #include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include<string.h>

void main()

{

char cp[50],rcp[50];

clrscr();

printf("enter any string\n");

scanf("%s",cp);

strcpy(rcp,cp);

strrev(rcp);

if(strcmp(cp,rcp)==0)

{

printf("palindrome");

}

else

{

printf("not a palindrome");

}

getch();

}

Post a Comment

0 Comments