Strings
Pre-lab reading materials
Until Chapter 6 on Zyante, especially 6.11 - 6.15.
Announcements
We will have a simple 5 minute quiz at the beginning of the lab on Blackboard. Please sign in to your Blackboard account and finish the quiz individually. To access the quiz, go to CS 141 course on Blackboard, and click on Lab Quizzes, there you can find Lab 4 quiz. To access the quiz, you will need a password, which will be announced by the TA in the lab.
The full version of lab assignment is on Blackboard, under the link "Lab Assignments" > "Lab 5 Programming Activity". To access the assignment, you need a password, which will be announced by the TA in the lab.
You must work with a single partner, in a group of 2. You must take turns being the “driver” and the “navigator”. (If there are an odd-number of students in the class, your TA will make an adjustment.)
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 submit your work onto Blackboard before your lab session ends & get graded by the TA in the lab. Late submission is not accepted. 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
During the lab 5 section, you need to implement three functions for providing 3 different utilities on strings, with progressing complexities. We will also supply a driver code for you to get you 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.
In Lab 5, you have to write a program that will provide the user with the following utilities:
Finding the length of a string (1 credit )
- Function will return the length of a given string
Searching a character in a string ( 1 credit )
- Function will return the index of the searched character inside the string, or -1 if not found
Checking whether a string is a palindrome ( 1 extra credit )
- Function 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"]
Create separate functions for each utility.
Allow the user to use the above functionalities repeatedly & specify their choice of functionality in every iteration.
Take user input depending on the functionality selected. Display the outcome in a well formatted way.
For your convenience, a driver code is attached (Lab5DriverCode.c). However, feel free to write your own code, as long as it works the way it is described above.