Sail E0 Webinar
Question


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;
}
Options:
A .  The code writes a text to a file
B .  The code reads a text files and display its content in reverse order
C .  The code writes a text to a file in reverse order
D .  None of above
Answer: Option B

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers