1. Write a C program that prompts the user to input a sentence that the program
ID: 3624649 • Letter: 1
Question
1. Write a C program that prompts the user to input a sentence that the program willthen convert to Pig Latin. This translation is performed by moving the first letter of
each word to the end of the word and appending the letters “ay”. For example, if
the user types the sentence, “His dog bit her cat.”, your program should print,
“isHay ogday itbay erhay atcay.”. You can assume that the end of each sentence is
identified with a period. Your program should be written using a function that
translates one individual word into Pig Latin. Your main function should then call
this translation function as many times as necessary to translate and print the entire
sentence.
I tried several ways... And I got it to work...However...I need to use the scanf() keyword to make the program terminate when a "." is entered.
Explanation / Answer
I'll give you pseudocode (This is assuming that yourfun, the function you wrote, does the conversion and prints it to screen.) : while(true) { char buff[256]; scanf("%s", buff); if(there is a period in buff) { remove period; yourfun(buff); print the period; break; } else { yourfun(buff); printf(" "); }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.