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

implement the pigLatin function such that it changes the input string to pigLati

ID: 3528968 • Letter: I

Question

implement the pigLatin function such that it changes the input string to pigLatin. Modify the actual input string. Do not make a new string. To make things simpler we will not follow all the rules of pigLatin. For our converter, simply take the first character of the string and move it to the end. Then add 'a' 'y' to the end of the string. For this part you may assume the input string will not be longer than 7 characters. /* You may NOT call any other string functions. * Do NOT include string.h. * Do NOT alter main in any way. */ void pigLatin(char w[]); int main () { char word[10]; printf("Word: "); scanf("%s", word); pigLatin(word); printf("Pig Latin Word: %s ", word); return 0; } /* Change word to pig latin. * Input word will contain at least one character. * Don't worry about words that start with a vowel. */ void pigLatin(char w[]) { /* Write code here */ }

Explanation / Answer

void pigLatin( char w[] ) {

char c;

int i;

c = w[0];

for( i=1; w[i] != ''; i++ ) {

w[i-1] = w[i];

}

w[i-1] = c;

w[i] = 'a';

w[i+1] = 'y';

w[i+2] = '';

}