C File Handling Questions Answers MCQ

21. What is the output of this program?

#include<stdio.h>
int main(){
char c;
FILE *fp;
fp=fopen("demo.txt","a+");
// demo.txt : hello you are reading a file
fprintf(fp," demo");
fclose(fp);
fp=fopen("myfile.txt","r");
while((c=fgetc(fp))!=EOF)
printf("%c",c);
fclose(fp);
return 0;
}

A. hello you are reading a file
B. hello you are reading a file demo
C. demo
D. None of the above

View Answer


22. A data of the file is stored in …

A. Ram
B. Hard disk
C. Rom
D. None

View Answer

23. Select a function which is used to write a string to a file…

A.pits()
B.putc()
C.fputs()
D.fgets()

View Answer


24. Select text file in which data is stored in

A. ASC11 code
B.Binary code
C.Octal code
D.text code

View Answer


25. We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind()

A. True
B. False

View Answer


26. Offset used in fseek() function call can be a negative number.

A. True
B. False

View Answer


27. Will the following program work?

#include<stdio.h>
int main()
{
int i=3;
printf("i=%*d\n", i, i);
return 0;
}

A. Yes
B. No

View Answer


28. stderr, stdin, stdout are FILE pointers

A. Yes
B. No

View Answer


29.which Is data type of file pointer is….

A. int
B. double
C. void
D. File

View Answer


30. In fopen(), the open mode "wx" is sometimes preferred "w" because.
1) Use of wx is more efficient.
2) If w is used, old contents of file are erased and a new empty file is created. When wx is used, fopen() returns NULL if file already exists.

A. Only 1
B. Only 2
C. Both 1 and 2
D. Neither 1 nor 2

View Answer







Also check :


Discussion


* You must be logged in to add comment.