int main(){ char sentence[81]; char temp[21]; char output[81]; int i,j=0; //counter for input and output int k,l; //counter for temp and counting consonant in a word
printf("Enter a sentence (up to 80 characters): ");
fgets(sentence,81,stdin);
for(;sentence[i]!='\n';i++) { for(;sentence[i]==' ';i++){} //skip the ' '
for(k=0;sentence[i]!=' ' && sentence[i]!='\n';i++,k++) { temp[k]=sentence[i]; //store a word in temp[] }
temp[k]='\0';
k=0;
for(l=0;(temp[k]!='a' )&& (temp[k]!='A' )&& (temp[k]!='e' )&& (temp[k]!='E' )&& (temp[k]!='i' )&& (temp[k]!='I' )&& (temp[k]!='o' )&& (temp[k]!='O' )&& (temp[k]!='u' )&& (temp[k]!='U');k++,l++){} //count the number of consonants
for(;(temp[k]!=' ') && (temp[k]!='.') && (temp[k]!='?') && (temp[k]!='!' )&& (temp[k]!='\0');k++,j++) { output[j]=temp[k]; }//move characters from temp to output, without '?' '.' '!'' '
for(k=0;k<l;k++,j++) { output[j]=temp[k]; } //translate a word to pig latin output[j]='a'; j++; output[j]='y'; k++; output[j]=' '; j++; }
j--;
for(;(sentence[i]==' ')||(sentence[i]=='\n');i--){}
if((sentence[i]=='.')||(sentence[i]=='!')||(sentence[i]=='?')) { output[j]=sentence[i]; }
j++; output[j]='\0';
printf("%s\n",sentence);
return 0;}


