Input / Output

Q1:
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;
}

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

ANS:A - The code writes a text to a file

This program reads the file INPUT.TXT and store it in the string str after reversing the string using strrev function.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.