Monday, 9 November 2015

C++ Program to Check Whether Given String is a Palindrome

Problem:- Write A C++ Program To Check String Is Palindrome Or Not or C++ Program to Check Whether Given String is a Palindrome or Check Given String is Palindrome or not in C++ or C++ Program to Check String is Palindrome or not or Program to check a string is palindrome or not or C++ Program to Check Whether String is Palindrome or C++ program to check whether given string is palindrome or not? or C++ Program to Check whether a string is A Palindrome or Not or C++ Program to Check Number is Palindrome or Not or C Program to Check if a Given String is A Palindrome.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Logic:- What Is Palindrome?

"a word, phrase, or sequence that reads the same backward as forwards"

" Matlab Ulta Seedha Ek Saman " or " मतलब उल्टा सीधा एक समान "

Simple if the string is "MADAM" compare the First letter index of 'M' to the last letter index of 'M' and again compare to 2nd letter index to the second last letter index if both are same then continue for next upcoming letters and repeat the same process continue to repeat if all Word's are same then String Is Palindrome.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page.

Try to Solve- Try to solve this problem for Numbers, Check weather number is Palindrome.

Solution:-


#include<iostream>
#include<string.h>
using namespace std;

int main()
{
/*Visit - www.programmingwithbasics.com*/
   
    cout<<"=====================================";
    cout<<"\nVisit - www.programmingwithbasics.com";
    cout<<"\n=====================================";
    
    while(1)
    {
    char string1[20];
    int i, length;
    int flag = 0;
    cout << "\n\nEnter a String: ";
    cin >> string1;
    length = strlen(string1);
    for(i=0;i < length ;i++)
  {
        if(string1[i] != string1[length-i-1])
  {
            flag = 1;
            break;
      }
  }
  cout<<"\n\n";
    if (flag) 
  {
        cout << string1 << "==> Is Not Palindrome " << endl;
    }  
    else 
{
        cout << string1 << "==> Is Palindrome " << endl;
    }
}
    return 0;
}

Output:-

C++ Program to Check Whether Given String is a Palindrome

You May Also See


1. C Program For Find The Gross Salary Of An Employee

2. C Program For Calculate Percentage Of 5 Subjects

3. C Program For Converting Temperature Celsius Into Fahrenheit

4. C++ Program To Find Character Is Vowel Or Not

5. C++ Program To Calculate Factorial Of A Given Number

6. C++ Program To Read Integer (N) And Print First Three Powers (N^1, N^2, N^3)

7. C++ Program To Swap Two Number Without Using Third Variable




Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment