Lab-8

Strings

Announcements

There will be 5 minutes’ quiz available on Blackboard at the beginning of each of the lab session. Please sign in to your Blackboard account and finish the quiz individually. Most of your time should be focused on finishing the lab activity question.

You must work with a single partner i.e., in a group of 2 (If there are an odd-number of students in the class, your TA will make an adjustment). You must take turns being the “driver” and the “navigator” while working on the lab activity.

Lab Grading policy 

You must work with a partner for credit. 

There are 3 questions. The maximum score is 2, where each question is worth 1 point. Question 3 is extra credit. To get a grade, you must get graded by the TA in the lab before the lab ends. TAs will not be grading after the 50 minutes of the lab session are over. Once you finish your work, please raise your hand and show your work to the TA during the last 10 minutes of lab or whenever you finish, the earlier of the two.

Lab Activity

You are required to implement three functions for providing 3 different utilities on strings, with progressing complexities. A driver code has been provided for this activity for you to get started. In order to complete these functions, you should review and have a firm knowledge about functions, parameter passing using functions (esp. call by reference), char array/string.

Instructions

Write a program that will provide the user with the following utilities:

1) Finding the length of a string (1 credit)

Write a function that will return the length of a given string

2) Searching a character in a string (1 credit)

Write a function that will return the index of the searched character inside the string, or -1 if not found

3) Checking whether a string is a palindrome (1 extra credit)

Write a function that will return a yes/No (0/1 or any other alternative) response to tell whether the given string is a palindrome [A palindrome is a word that reads the same when read from front-to-back or from back-to-front. E.g. "madam", ”racecar”]

 

Allow the user to use the above functionalities repeatedly (loop do-you-want-to-continue) & specify their choice of functionality in every iteration (for example: “You chose to find the length of the string”).

Take user input depending on the functionality selected. Display the outcome in a well formatted way.

For your convenience, a driver code is attached (Lab8DriverCode.c). However, feel free to write your own code, as long as it works the way it is described above.