Description
The purpose of this challenge is to manually manipulate character arrays. This challenge determines the correct article to use on an English noun.
Requirements
- In English, the articles a and an are used to describe a singular noun. If the noun begins with a vowel (a,e,i,o,u), then the article used is an. If the noun begins with a consonant, then the article used is a. For example, an egg, a duck, an image, a phone. Additionally, if the “word” is an initialism or an acronym that is written in all UPPERCASE such as HMO, ATM, MMA, then the an article is used for a vowel-sounding letter. The vowel-sounding letters in English are F, H, L, M, N, S.
- Create a void function void get_article(char noun[], char article[]). Do NOT cout or cin in this function. The noun array represents a noun which is entered by the user and passed into this function. The article array represents the article (a or an) that is the correct article for noun.
- You can create as many supporting functions as necessary.
- Ask the user to enter a string. Use cin.getline(noun, 50) function call to get the string from the user, where noun is a character array that receives the user input.
- Show the word with its appropriate article
Sample Interaction / Output
What do you have? egg You have an egg
Run it again
What do you have? mouse You have a mouse
Run it again
What do you have? HMO You have an HMO
Run it again
What do you have? NDA You have an NDA
Run it again
What do you have? DVD You have a DVD
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-CHAL0037
Print Requirements