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

IN C- Programming!!!! Pig Latin Program: Write a program that encodes English-la

ID: 3687021 • Letter: I

Question

IN C- Programming!!!!

Pig Latin Program: Write a program that encodes English-language phrase, tokenize the phrase into words with function strtok. To translate each English word into a pig-latin word, place the first letter of the English word at the end of the English word and add the letters “ay”. Thus the word “jump” becomes “umpjay”, the word “the” become “hetay” and the word “computer” becomes “omputercay”. Blacks between words remain as blanks. Assume the following: The English phrase consists of words separated by blanks, there are no punctuation marks, and all words have two or more letters.

The sample program execution is as follows:
Enter your phrase: hello happy birthday joey
Pig-Latin phrase is: ellohay appyhay irthdaybay oeyjay

Explanation / Answer

try this once

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char pig(char[]);
int main()
{
char english[30],piglatin[40],s[2]=" ";
char *token;
printf("enter english prase:");
scanf("%s",english);
token = strtok(english, s);
/* walk through other tokens */
while( token != NULL )
{

strcat(piglatin,pig(token));

token = strtok(NULL, s);
}
printf(" piglatin phrase is: %s",piglatin);
}
char pig(char en[])
{
int t=0;
char w=en[0];
while(en[t]!='')
{
en[t]=en[++t];
}
en[t-1]="";
strcat(en,w);
strcat(en,"ay");
strcat(en," ");
return *en;
}