Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions