Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. int main()
  6. {
  7. int charCount, counter, i, temp, check,check2;
  8. char letter[12], letter2[12];
  9. charCount = 0;
  10. counter = 10;
  11. check = 0;
  12. i = 1;
  13. check2 = 0;
  14.  
  15. printf("Enter your sentinel value.:");
  16. scanf_s(" %c", &letter[check2]);
  17.  
  18.  
  19. while ((i<13) && (letter[i] != letter[check2]))
  20. {
  21. printf("Enter individual letters in word (in order).:");
  22. scanf_s(" %c", &letter[i]);
  23.  
  24. charCount++;
  25.  
  26. if (letter[i] == letter[check2])
  27. {
  28. break;
  29. }
  30. i++;
  31.  
  32. }
  33.  
  34.  
  35. printf("Letters entered:%in", charCount);
  36.  
  37.  
  38. for (i = 0; i < charCount; i++)
  39. {
  40. letter2[i] = letter[i];
  41. }
  42.  
  43. for (i = 0; i <= (charCount / 2); i++)
  44. {
  45. temp = letter2[counter];
  46. letter2[counter] = letter2[i];
  47. letter2[i] = temp;
  48. counter--;
  49. }
  50.  
  51. for (i = 0; i <= charCount; i++)
  52. {
  53. if (letter[i] = letter2[i])
  54. {
  55. check++;
  56. }
  57. }
  58.  
  59. if (check = charCount)
  60. {
  61. printf("Word is a palindrome.n");
  62. }
  63.  
  64. system("PAUSE");
  65. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement