C++ Programming

C++ Program to Check Entered String is Palindrome or Not

palindrome string

Write a Program to Check Entered String is Palindrome or Not

Source Code

#include<iostream>

#include<string.h>

#include<conio.h>

using namespace std;

int main()

{

char s[10];

int i,n,m,flag=0;

cout<<"enter a string: ";

cin>>s;

m=strlen(s);

n=m-1;

for(i=0;i<=m/2;i++,n--)

{

if(s[i]!=s[n])

    {

        flag++;

        break;

    }

    }  

    if (flag==0)

        cout<<endl<<s<<" string is palindrome";

    else

        cout<<endl<<s<<" string is not palindrome";

    getch();

}

Output

palindrome string

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of