
// program to check whether the string is palindrome or not
If not make it a palindrome by adding to its end
#include<iostream.h>
int main()
{
     char str[80],temp[80];
     int i=0,n=0,flag;
     cout<<"Enter string to check \n ";
     cin>>str;
     while(str[i]!='\0')
     {
          ++n;
          ++i;
     }
     for(i=0;i<n/2;i++)
     {
          if(str[i]!=str[n-i-1])
          {
               flag=0;
               break;
          }
          else flag =1;
     }
     if(flag==1)
     cout<<"\n Given string is palindrome";
     else
     {
          for(i=0;i<n-1;i++)
          str[n+i]=str[n-i-2];
          str[n+i]='\0';
          cout<<"\n Given string is converted to palindrome";
          cout<<str;
       }
   return 0;
}
Test data 1
Enter string to check
madam
output
Given string is palindrome
Test data 2
Enter string to check
mouse
Output
Given string is converted to palindrome
mousesuom