Palindrome string program in C++

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

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<iostream.h>
	#include<conio.h>
		
	//PALINDROME NUMBER PROGRAM
	void main()
	{
		char *a;
		int i,len,flag=0;
		clrscr();
		cout<<"\nENTER A STRING:- ";
		cin>>c;
		
		len=strlen(a);
		
		for (i=0; i<len; i++)
		{
			if(a[i]==a[len-i-1])
			{
				flag=flag+1;
			}
		}
		
		if(flag==len)
		{
			cout<<"\nTHE STRING IS PALINDROM.";
		}
		else
		{
			cout<<"\nTHE STRING IS NOT PALINDROM.";
		}
			
		getch();
	}
	

Output:


	ENTER A STRING:- MAM
	THE STRING IS PALINDROM.

Post Your Comment