Lecture 19:  Strings

Activity:  Programming



We saw in today's lecture the use of a new concept called strings.  You will have a chance to use this new concept as well as functions from the string library.

Here's your task:  Write a program that takes nouns and displays their plural form according to these rules:
1.  If the noun ends in "y", remove the "y" and add "ies".
2.  If the noun ends in "s", "ch", or "sh" add "es".
3.  In all other cases just add "s".

Your program should prompt the user to enter a noun and display the plural form.  If the user enters the word "done", then the program should terminate.  You may assume each entered word is less than 48 characters long.

After you have finished writing the code, be sure to test your program (hand trace) on several nouns.  Some examples include "chair", "dairy", "boss", "science", "circus", "computer", "church", and "dish".

Be sure that when planning your solution, you make use of the string library functions.

Just like the other exercises, it is important to proceed with the following steps:  program specification, the algorithm and basic design of the program, and then the implementation of the C code.

Problem Specification:
 
 
 
 
 

The Algorithm:
 
 
 
 
 
 
 

The C Program: