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

C Program compaitabile with visual studio please. Good answer will be rated. The

ID: 3822952 • Letter: C

Question

C Program compaitabile with visual studio please. Good answer will be rated.
The following is the content of the text file PiglatinIn.txt

:

Program 1 English to Pig Latin Introduction As most of you know, pig Latin is a language game played with English words. It is based on discriminating between vowels and consonants within the word. (Note that a "vowel" is any of the characters "a 'e', 'i', o', or 'u'. A "consonant" is any non-vowel character.) Any English word can be converted to its pig Latin equivalent by using the following algorithm: l) Starting from the first character of the word, locate the position of the first vowel. 2) If there is a consonant (or a string of consonants) to the left of that position, do the following: a) Extract the leading consonant(s) from the word. What remains will begin with a vowel by definition. Let's call that the "residual string." b) Append an "ay" to the end of the consonant string creating a "suffix string c) Append the suffix string to the end of the residual string using a hyphen. 3) If the first letter of the word is a vowel, then append "-way" to the end of the word. For example, let's say we want to convert the word "cabin" to pig Latin. Following the above steps, we do the following: 1) We locate the position of the first vowel. This is the 'a' that occurs at index 1 in the string (i.e., it is the second letter in the string). 2) Since there is a leading consonant in this case, "c', it is removed from the word creating the residual string abin a) We take the consonant, c', append an "ay" to it, creating the suffix string cay b) We append that to the end of the residual string using a hyphen.

Explanation / Answer

Code:

C++ code

#include<iostream>
#include<string.h>
#include<fstream>
int isVowel(char c)
{
if (c=='a' || c=='e'|| c=='i'|| c=='o' ||c=='u' ||c=='A' || c=='E'|| c=='I'|| c=='O' ||c=='U' )
return 1;
return 0;
}
using namespace std;
char * converTopigLatin(char *eng, char * platin)
{
int i;
if(isVowel(eng[0]))
{
for( i=0;i<eng[i];i++)
platin[i]=eng[i];
platin[i++]='-';
platin[i++]='w';
platin[i++]='a';
platin[i++]='y';
platin[i++]='';
}
else
{
int first_vowel=0;
char consonent_string[100];
int j=0;
for( int i=0; eng[i]!='';i++)
{
if(isVowel(eng[i]))
{
first_vowel=i;
break;
}
else
{
consonent_string[j]=eng[i];
j++;
}
}
consonent_string[j++]='a';
consonent_string[j++]='y';
consonent_string[j++]='';
int d=0;
for(int i=first_vowel;eng[i]!='';i++)
{
platin[d]=eng[i];
d++;
}
platin[d++]='-';
platin[d++]='';
strcat(platin,consonent_string);

}
return platin;

}
int main()
{
char platin[100];
char *p;

std::ifstream myfile;
std::ofstream ofs ("C:/Users/i310016/Desktop/chegg/output.txt", std::ofstream::out);
char word[100];
myfile.open("C:/Users/i310016/Desktop/chegg/eng.txt");
ofs<<"English word"<<" "<<"Pig latin Word"<<endl;
ofs<<"------------"<<" "<<"--------------"<<endl<<endl;
while(myfile>>word)
{
ofs<<word<<" "<<converTopigLatin(word,platin)<<endl;
}
return 1;
}

output:

outfile looks like

English word   Pig latin Word
------------   --------------

go   o-gay
placidly   acidly-play
amid   amid-way
the   e-thay
noise   oise-nay
and   and-way
haste   aste-hay
and   and-way
remember   emember-ray
what   at-whay
peace   eace-pay
there   ere-thay
may   ay-may
be   e-bay
in   in-way
silence   ilence-say
as   as-way
far   ar-fay
as   as-way
possible   ossible-pay
without   ithout-way
surrender   urrender-say
be   e-bay
on   on-way
good   ood-gay
terms   erms-tay
with   ith-way
all   all-way
persons   ersons-pay
speak   eak-spay
your   our-yay
truth   uth-tray
quietly   uietly-qay
and   and-way
clearly   early-clay
and   and-way
listen   isten-lay
to   o-tay
others   others-way
even   even-way
the   e-thay
dull   ull-day
and   and-way
the   e-thay
ignorant   ignorant-way
they   ey-thay
too   oo-tay
have   ave-hay
their   eir-thay
story   ory-stay
if   if-way
you   ou-yay
compare   ompare-cay
yourself   ourself-yay
with   ith-way
others   others-way
you   ou-yay
may   ay-may
become   ecome-bay
vain   ain-vay
or   or-way
bitter   itter-bay
for   or-fay
always   always-way
there   ere-thay
will   ill-way
be   e-bay
greater   eater-gray
and   and-way
lesser   esser-lay
persons   ersons-pay
than   an-thay
yourself   ourself-yay
enjoy   enjoy-way
your   our-yay
achievements   achievements-way
as   as-way
well   ell-way
as   as-way
your   our-yay
plans   ans-play
be   e-bay
yourself   ourself-yay
especially   especially-way
do   o-day
not   ot-nay
feign   eign-fay
affection   affection-way
beyond   eyond-bay
a   a-way
wholesome   olesome-whay
discipline   iscipline-day
be   e-bay
gentle   entle-gay
with   ith-way
yourself   ourself-yay
you   ou-yay
are   are-way
a   a-way
child   ild-chay
of   of-way
the   e-thay
universe   universe-way
no   o-nay
less   ess-lay
than   an-thay
the   e-thay
trees   ees-tray
and   and-way
the   e-thay
stars   ars-stay
you   ou-yay
have   ave-hay
a   a-way
right   ight-ray
to   o-tay
be   e-bay
here   ere-hay
and   and-way
whether   ether-whay
or   or-way
not   ot-nay
it   it-way
is   is-way
clear   ear-clay
to   o-tay
you   ou-yay
no   o-nay
doubt   oubt-day
the   e-thay
universe   universe-way
is   is-way
unfolding   unfolding-way
as   as-way
it   it-way
should   ould-shay
be   e-bay
cheerful   eerful-chay
strive   ive-stray
to   o-tay
be   e-bay
happy   appy-hay

C code:

#include<stdio.h>
int isVowel(char c)
{
if (c=='a' || c=='e'|| c=='i'|| c=='o' ||c=='u' ||c=='A' || c=='E'|| c=='I'|| c=='O' ||c=='U' )
return 1;
return 0;
}

char * converTopigLatin(char *eng, char * platin)
{
int i;
int d=0;
if(isVowel(eng[0]))
{
for( i=0;i<eng[i];i++)
platin[i]=eng[i];
platin[i++]='-';
platin[i++]='w';
platin[i++]='a';
platin[i++]='y';
platin[i++]='';
}
else
{
int first_vowel=0;
char consonent_string[100];
int j=0,i=0;
for(i=0; eng[i]!='';i++)
{
if(isVowel(eng[i]))
{
first_vowel=i;
break;
}
else
{
consonent_string[j]=eng[i];
j++;
}
}
consonent_string[j++]='a';
consonent_string[j++]='y';
consonent_string[j++]='';

for(i=first_vowel;eng[i]!='';i++)
{
platin[d]=eng[i];
d++;
}
platin[d++]='-';
platin[d++]='';
strcat(platin,consonent_string);

}
return platin;

}
void main()
{
char platin[100];
char *p;
char word[100];
char buf[100];

FILE *fp = fopen("C:/Users/i310016/Desktop/chegg/pigLatinInput.txt","r");
FILE *fp_w = fopen("C:/Users/i310016/Desktop/chegg/pigLatinOut.txt","w");
while( fscanf(fp, "%s", buf) != EOF )
{
fprintf(fp_w,"%s ", converTopigLatin(buf,platin));
}
printf("Output is written to pigLatinOut.txt ");
}

Dear friend hope this helps you.