#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main(int argc, char *argv[])
{
  char theWord[100];
  char copy[200];
  char temp[200];
  if(argc != 2)
  {
	printf("Error: Usage is %s someword\n", argv[0]);
	exit(-1);
  }
  strcpy(theWord, argv[1]);
  int n = strlen(theWord);
  int upperIndex;
  if(n % 2 == 0)  //if n is even
    upperIndex = n/2 - 1;
  else
    upperIndex = ((n - 1) / 2) - 1 ;
  int i;
  int isPal = 1;
  for(i = 0; i<=upperIndex; i++)
  {
    if(theWord[i] != theWord[n-i-1])
	isPal = 0;
  }
  if(isPal)
    printf("%s is a palindrome.\n",theWord);
  else
  {
    printf("%s is not a palindrome.\n",theWord);
    strcpy(copy,theWord);
    //put a "reversed" copy of copy into temp
    for(i=0; i<n; i++)
      temp[n-i-1] = copy[i];
    temp[n] = '\0';

    //concat temp onto the back of copy
    strcat(copy,temp);
    printf("But %s is a palindrome.\n",copy);
  }
}
