Palindrome String Program in C

In this section you will learn how to make palindrome string program in C.

Palindrome String Program

What is palindrome string?

A palindrome is a string such that if you reverse it, it will not change. The string will be remain same and meaning also remain same.

Example of palindrome string.

Mom, Malayalam, Wow, Deleveled, etc.

How program will work?

Program of palindrome string in c.


	#include<stdio.h>
	#include<conio.h>
		
	//PALINDROME NUMBER PROGRAM
	void main()
	{
		char *a;
		int i,len,flag=0;
		clrscr();
		printf("\nENTER A STRING:- ");
		scanf("%s",a);
		
		len=strlen(a);
		
		for (i=0; i<len; i++)
		{
			if(a[i]==a[len-i-1])
			{
				flag=flag+1;
			}
		}
		
		if(flag==len)
		{
			printf("\nTHE STRING IS PALINDROM.");
		}
		else
		{
			printf("\nTHE STRING IS NOT PALINDROM.");
		}
			
		getch();
	}
	

Output:


	ENTER A STRING:- MAM
	THE STRING IS PALINDROM.

Post Your Comment