Question: Exercise 2 (THIS IS FOR C PROGRAMMING) Filename: piglatin.c Write a function, called ToPigLatin , which is described below: Write a function for which the

Exercise 2 (THIS IS FOR C PROGRAMMING)

Filename: piglatin.c

Write a function, called ToPigLatin, which is described below:

  • Write a function for which the prototype is shown below:

char* ToPigLatin(char* sentence);

This function receives a c-style string (word) as a parameter.

  • You are to define this function so that it converts the incoming string (character array) to its "Pig Latin" version, and then have the function return a pointer to the string
  • For our purposes, we will use the following as the rules for translation of a word into "Pig Latin":
    1. A sentence is a consecutive sequence of letters (a-z, A-Z) or apostrophes with space. Examples: I am a cat
    2. If a word starts with a vowel, the Pig Latin version is the original word with "way" added to the end
    3. If a word starts with a consonant, or a series of consecutive consonants, the Pig Latin version transfers all consonants up to the first vowel to the end of the word, and adds "ay" to the end.
    4. The letter 'y' should be treated as a consonant if it is the first letter of a word, but treated as a vowel otherwise.
    5. If the original word is capitalized, the new Pig Latin version of the word should be capitalized in the first letter (i.e. the previous capital letter may not be capitalized any more).
  • You may assume that a "sentence" to be entered into the function is no more than 39 characters.

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!