Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program to check whether a word is palindrome or not (using classes & pointers )

Posted By: Easy Tutor     Category: C++ Programming     Views: 15983

A C++ Program to check whether a word is palindrome or not (using classes & pointers ).

Code for Program to check whether a word is palindrome or not (using classes & pointers ) in C++ Programming

 #include<iostream.h>
 #include<string.h>
 #include<conio.h>


 /*************************************************************************///----------------------------  palindrome  -----------------------------///*************************************************************************/class palindrome
    {
       private:
        char word[25];

       public:
        void get_value();
        void show_value();
    };


 /*************************************************************************///---------------------------  get_value( )  ----------------------------///*************************************************************************/void palindrome::get_value()
    {
       cout<<"\n Enter the word : ";
       cin.getline(word,25);
    }

 /*************************************************************************///--------------------------  show_value( )  ----------------------------///*************************************************************************/void palindrome::show_value()
    {
       charstring[20];

       int flag_1 =0;
       int count_1=0;
       int flag_2 ;
       int flag_3=0;

       while(word[count_1]!='\0')
      {
         flag_1 =flag_1 +1;
         count_1++;
      }

       flag_2 =flag_1 /2;

       for(int count_2=flag_1 -1,count_3=0;count_2>flag_2 ,count_3<=flag_2 ;
                            count_2--,count_3++)
      string[count_3]=word[count_2];

       for(int m=0;m<flag_2 ;m++)
      {
         if(string[m]==word[m])
        flag_3=flag_3+1;
      }

       if(flag_3==flag_2 )
      cout<<"\n\t The word is Palindrome "<<endl;

       else
      cout<<"\n\t The word is not Palindrome"<<endl;
    }

 /*************************************************************************//*************************************************************************///-----------------------------  Main( )  -------------------------------///*************************************************************************//*************************************************************************/

 main( )
    {
       clrscr();

       palindrome s;

       char x;

       do
      {
         s.get_value();
         s.show_value();

         cout<<"\n Do you want to continue ( y/n )? : ";
         cin>>x;
      }
       while(x=='y');

       getch();
       return 0;
    }
  
Share: 



Easy Tutor
Easy Tutor author of Program to check whether a word is palindrome or not (using classes & pointers ) is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!