String Manipulation Lab 


Lab 9. Manipulate a word using library functions.

  • Declare an array to store one word.
  • Prompt operator to enter a word.
    1. Call the string length library function (strlen) to display the length of the word.
      • This replaces your string length function.
    2. Convert the word to uppercase.  (Display from main).
      • HOW:  Pass the word.
      • Set up a loop looking for the NULL.
        • Within the loop, call the library function (toupper) to convert each character to uppercase.
    3. Determine if the word is a palindrome (spelled same backward as forward -- example: radar, deed, civic).
      • HOW:  Write a function to copy the word in reverse order.
      • Use the string compare library function (strcmp) to compare the original word with the reversed word.
      • Report the results in main.

Test Data:
    level
    racecar
    banana
    peep

Submit:
    Source code
    Output

Back to Top

! You are using a version 4 browser or older. If you are experiencing any problems with scrolling, please reload the page.