loader image

C program to check palindrome string

Aim: Check whether a given string is palindrome or not using C.

#include<stdio.h>
#include<conio.h>
main()
{
	char str[50];
	int i,j,palindrome=1;
	printf("Enter a string : ");
	scanf("%s",str);
	for(j=0;str[j+1]!='\0';j++)
	;
	for(i=0;i<j;i++,j--)
	if(str[i]!=str[j])
	{
		palindrome=0;
		break;
	}
	if(palindrome)
            printf("\n%s is palindrome",str);
	else
            printf("\n%s is not palindrome",str);
	return 0;
}
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top