fork(11) download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define N 50
  4. int main()
  5. {
  6. char array[N] = {0};
  7. char front;
  8. char end;
  9. char x;
  10. char w=0;
  11. char i;
  12. char forward[N];
  13. char reverse[N];
  14.  
  15. printf("Enter Message: ");
  16. gets(array);
  17.  
  18. front = strlen(array);
  19. end = strlen(array) - 1;
  20. for( i = 0; i <= front; i++)
  21. {
  22. forward[i]= array[i];
  23.  
  24. }
  25. for( i=0,x = end; x >= 0; i++,x--)
  26. {
  27. reverse[i]= array[x];
  28. }
  29. reverse[i]=0;
  30. if (strcmp(forward,reverse)!=0)
  31. {
  32. w ='1';
  33. }
  34.  
  35. if(w == '1')
  36. {
  37. printf("Not a Palindrome");
  38. }
  39. else{
  40. printf("Palindrome");
  41. }
  42.  
  43. printf("\n");
  44. return 0;
  45. }
Success #stdin #stdout 0s 2900KB
stdin
nayan
stdout
Enter Message: Palindrome