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

Here is the Code: #include <stdio.h> #include <stdlib.h> #include <string.h> #in

ID: 3612803 • Letter: H

Question

Here is the Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main()
{int i,j;
char str[80];
bool isvowel;
char vowel[11]={"AEIOUaeiou"};
char *in;
FILE *file;
char * pch;
char wd[50];
if(!(file=fopen("input.txt","r")))
{
    printf(" Error opening file ");
    getch();
    return 1;
}
in=fgets(str,80,file);
while(in!=NULL)
{pch = strtok (str," ,.-?!;:");
while (pch != NULL)
{ isvowel=false;
    for(i=0;i<10;i++)
        if(pch[0]==vowel[i])
           isvowel=true;
        if(isvowel)
             {for(j=0;j<strlen(pch);j++)
              if(pch[j]!=' ')
                 wd[j]=pch[j];
              wd[j]='';
              strcat(wd,"ay");
             }
         else
            {for(j=1;j<strlen(pch);j++)
                if(pch[j]!=' ')
                   wd[j-1]=pch[j];                 
              wd[j]='';
              strcat(wd,"ay");             
              }       
    for(j=0;j<strlen(wd);j++)
        printf ("%c",wd[j]);
    printf(" ");    
    pch = strtok (NULL, " ,.-?!;:");
}
printf(" ");
in=fgets(str,80,file);
}
getch();
return 0;
}


The input simply said: Walt Disney World is the most fun place onEarth.

The output wrote: altay isneyay orldyay isay heaay ostaay untaylaceyay onay Earthay.

Also what would this code write so the user can input any sentencerather than the program take it from a file?

Explanation / Answer

please rate - thanks choice of keyboard or file when done with input type ctrl Z which is end of file #include #include #include int main() {int i,j; char str[80]; bool isvowel; int choice; char vowel[11]={"AEIOUaeiou"},first; char *in; FILE *file; char * pch; char wd[50]; printf("input from file or keyboard (1 for file 0 for keyboard)?"); scanf("%d",&choice); if(choice==1) if(!(file=fopen("input.txt","r"))) {     printf(" Error opening file ");     getch();     return 1; } if(choice==1) in=fgets(str,80,file); else    {    in=gets(str);    } while(in!=NULL) {pch = strtok (str," ,.-?!;:"); while (pch != NULL) { isvowel=false;     for(i=0;i