Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that encodes English languagephrases into pig Latin. Pig Latin i

ID: 645610 • Letter: W

Question

Write a program that encodes English languagephrases into pig Latin. Pig Latin is a form of coded language oftenused for amusement. Many variations exist in the methods used toform pig Latin phrases. For simplicity, use the followingalgorithm: To form a pig-Latin phrase from an English-languagephrase, tokenize the phrase into words with functionstrtok. To translate each English word into a pig-Latinword, place the first letter of the English word at the end of theEnglish word and add the letters "ay." Thus, the word"jump" becomes "umpjay," the word "the"becomes "hetay" and the word "computer" becomes"omputercay." Blanks between words remain as blanks.Assume that the English phrase consists of words separated byblanks, there are no punctuation marks and all words have two ormore letters. FunctionprintLatinWord should display eachword. [Hint: Each time a token isfound in a call to strtok, pass the token pointer tofunction printLatinWord and print the pig-Latin word. Thislab should be implemented using C-style, pointer-basedstrings.]

Extra credit [20 points]: tomake sure your pig Latin word is pronounceable, follow theserules:

1. If the first letter is a vowel, place "way"at the end to form a pig Latin word.

2. Move the consonant(s) to the end of the wordand append "ay" to it. You may have one or more consonants beforeyou see the first vowel.

Explanation / Answer

#include <stdio.h>
#include <string.h>
pigLatinWord(char word[]){
if(word[0]=='a'||word[0]=='e'||word[0]=='i'||word[0]=='o'||word[0]=='u'){
word[sizeof(word)]='w';
word[sizeof(word)+1]='a';
word[sizeof(word)+2]='y';
printf("%s ", word);
}
else{
char temp;
int k=1,r=0;
while(word[k]!=''){
temp[r]=word[k];
r++;
k++;
}
temp[sizeof(temp)]=word[0];
temp[sizeof(temp)+1]='a';
temp[sizeof(temp)+2]='y';
printf("%s ", temp);
}
}
int main() {
char str[512], word[256];
int i = 0, j = 0;
printf("Enter your input string:");
fgets(str, 512, stdin);
str[strlen(str) - 1] = '';
/* checking whether the input string is NULL */
if (str[0] == '') {
printf("Input string is NULL ");
return 0;
}
/* printing words in the given string */
while (str[i] != '') {
/* ' ' is the separator to split words */
if (str[i] == ' ') {
word[j] = '';
pigLatinWord(word);
j = 0;
} else {
word[j++] = str[i];
}
i++;
}

word[j] = '';

/* printing last word in the input string */
printf("%s ", word);
return 0;
}

I ddnt done testing...if sysntax errors ignore

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote