Input / Output - General Questions Multiple Questions and Answers.




6.Which files will get closed through the fclose() in the following program?
A. "A.C" "B.C" "C.C"
B. "B.C" "C.C"
C. "A.C"
D. Error in fclose()

7.On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?
#include<stdio.h>
int main()
{
    int i, fss;
    char ch, source[20] = "source.txt", target[20]="target.txt", t;
    FILE *fs, *ft;
    fs = fopen(source, "r");
    ft = fopen(target, "w");
    while(1)
    {
        ch=getc(fs);
        if(ch==EOF)
            break;
        else
        {
            fseek(fs, 4L, SEEK_CUR);
            fputc(ch, ft);
        }
    }
    return 0;
}
A. r n
B. Trh
C. err
D. None of above

8.To scan a and b given below, which of the following scanf() statement will you use?
A. scanf("%f %f", &a, &b);
B. scanf("%Lf %Lf", &a, &b);
C. scanf("%f %Lf", &a, &b);
D. scanf("%f %lf", &a, &b);

9.Out of fgets() and gets() which function is safe to use?
A. gets()
B. fgets()
C. gets() and fgets()
D. None of above

10.Consider the following program and what will be content of t?
A. size of "DUMMY.C" file
B. Garbage value
C. Error in fileno()
D. The handle associated with "DUMMY.C" file

«»



Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers