Thursday, December 7, 2017

C++ Code Review: Shows entered word is Palindrome or not.

Description: This program shows entered word is Palindrome or not.

Code:

//Compiling Tool: Code::Block IDE with MinGW

//Program shows entered word is Palindrome or not.

 

#include<iostream>

 

using namespace std;

 

int main()

{

    int i,j,len,flag=1;

    char a[20];

 

    cout<<"Enter a string:";

    cin>>a;

 

    for(len=0;a[len]!='\0';++len);

 

    for(i=0,j=len-1;i<len/2;++i,--j)

    {

        if(a[j]!=a[i])

            flag=0;

    }

 

    if(flag==1)

        cout<<"\nThe string is Palindrome";

    else

        cout<<"\nThe string is not Palindrome";

 

    return 0;

}         

 

Output:

clip_image002

If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects. For book sample click this link.

Add your comments in below available comment box.

Note: Click these label/tags to view all related posts. Tags: C++Code

 

…till next post, bye-bye & take care.

No comments:

Post a Comment