C LANGUAGE TUTORIAL-(2)-PALINDROME STRING
PALINDROME STRING
"Palindrome" is a greek word;the world "palin" means back and "drome" means direction.a string is said to be palindrome if by moving forward and reverse traversal we get the same result.lets take an example:-if we consider "malayalam" string as a input,so by moving start to end(forward traversal)and end to start(reverse traversal)we will get the same result,so we can say this is palindrome,on the other hand if we take the word"electronics",then it is non-palindrome because if we take the backward traversal we are getting "scinortcele"(reverse of the word electronics).
Example:-"madam","malayalam","civic".
Flowchart:-
Program code using c:-
CODE:-
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[25];
int l,i;
printf("enter the string that need to be chcek:- ");
gets(str);
l=strlen(str);
for(i=0;i<l/2;i++)
{
if(str[i]!=str[l-1-i])
{
printf("oops!!!!this is not palimdrome");
break;
}
}
if(i==l/2)
{
printf("palindrome");
}
}
OUTPUT SCREEN:-
case-1 |
case-2 |
Comments
Post a Comment