Programme to check whether string is pallindrome or not.
String is pallindrome or not
This is the c languge code to check whether the string is pallindrome or not.
Pallindrome: It is a string that reads the same backward as well as forward and can be of odd or even length.
Example: radar, madam, pop, lol, etc.
My programme follow the following steps:
- Take string (let x) input from user.
- Copy that string into other string(let y).
- Then reverse the first string(x).
- Compare the x and y.
- If both are same then x is pallindrome and if they are not same then x is not pallindrome.
Programme to check whether the string is pallindrome or not.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
clrscr();
char str1[30],str2[30];
int i,option;
printf("Enter string\n");
gets(str1);
strcpy(str2,str1);
strrev(str1);
option=strcmp(str1,str2);
if(option==0)
{
printf("Given string is pallindrome\n");
}
else
else
{
printf("Given string is not pallindrome\n");
printf("Given string is not pallindrome\n");
}
getch();
getch();
}
Hope you like this C programme.
If you like please don't be cheap to comment for any improvement.
Programme to check whether string is pallindrome or not.
Reviewed by Deepak kumar soni
on
December 27, 2018
Rating:
No comments: