Question
#include<stdio.h>
int main()
{
FILE *fp;
char str[11], ch;
int i=0;
fp = fopen("INPUT.TXT", "r");
while((ch=getc(fp))!=EOF)
{
if(ch == '\n' || ch == ' ')
{
str[i]='\0';
strrev(str);
printf("%s", str);
i=0;
}
else
str[i++]=ch;
}
fclose(fp);
return 0;
}
Which of the following statement is correct about the program?
#include<stdio.h>
int main()
{
FILE *fp;
char str[11], ch;
int i=0;
fp = fopen("INPUT.TXT", "r");
while((ch=getc(fp))!=EOF)
{
if(ch == '\n' || ch == ' ')
{
str[i]='\0';
strrev(str);
printf("%s", str);
i=0;
}
else
str[i++]=ch;
}
fclose(fp);
return 0;
}
Answer: Option B
Was this answer helpful ?
This program reads the file INPUT.TXT and store it in the string str after reversing
the string using strrev function.
Was this answer helpful ?
Submit Solution