Question: Write a function: void plurals(char * noun, char * plural) that takes an input word (noun) and outputs its plural (plural) on the basis of

Write a function: void plurals(char * noun, char * plural) that takes an input word (noun) and outputs its plural (plural) on the basis of these rules:

If the noun ends in y, remove the y and add ies

If the noun ends in s, ch, or sh, add es

In all other cases, just add s

Hints: given the string noun, you should first check its length L by using strlen function. Then, you should check if the last letter of noun is y. If yes, you should copy the first L-1 letters of noun to plural, and concatenate string ies to it. If no, you should check if noun ends with s, ch, or sh and make the similar actions. In all other cases, you should just copy noun to plural and then concatenate s to its end. You should remember to add null symbol \0 after the last letter in plural string. Using the plurals function, write a program which, in a loop:

1. Prompts user to enter a string and reads it from input

2. Passes the string to function plurals, which finds its plural

3. Prints out the plural string 4. Prompts the user to do another by typing y, or to quit the program by typing anything else.

Sample Output: Supply noun:chair

The plural is:chairs

Do Another (y/n)?y

Supply noun:dairy

The plural is:dairies

Do Another (y/n)?y

Supply noun:boss

The plural is:bosses Do Another (y/n)?y

Supply noun:circus

The plural is:circuses

Do Another (y/n)?y

Supply noun:fly

The plural is:flies

Do Another (y/n)?n Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!