Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions