

MCQOPTIONS
Saved Bookmarks
This section includes 22 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Will the following program work? |
A. | Yes |
B. | No |
C. | May Be |
D. | Can't Say |
Answer» B. No | |
2. |
What is the meant by 'a' in the following operation? |
A. | Attach |
B. | Append |
C. | Apprehend |
D. | Add |
Answer» C. Apprehend | |
3. |
What does the following segment of code do? |
A. | It writes "Copying!" into the file pointed by fp |
B. | It reads "Copying!" from the file and prints on display |
C. | It writes as well as reads "Copying!" to and from the file and prints it |
D. | None of the mentioned |
Answer» B. It reads "Copying!" from the file and prints on display | |
4. |
In fopen(), the open mode "wx" is sometimes preferred "w" because |
A. | Only 1 |
B. | Only 2 |
C. | Both 1 and 2 |
D. | Neither 1 nor 2 |
Answer» C. Both 1 and 2 | |
5. |
A data of the file is stored in a |
A. | Ram |
B. | Hard disk |
C. | Rom |
D. | None |
Answer» C. Rom | |
6. |
Select text file in which number will take. |
A. | 2 bytes |
B. | 4 bytes |
C. | 3 bytes |
D. | 8 bytes |
Answer» C. 3 bytes | |
7. |
Which of the following is data type of file pointer? |
A. | int |
B. | double |
C. | void |
D. | File |
Answer» E. | |
8. |
getc() returns EOF when |
A. | When getc() fail to read the character |
B. | When end of file is reached |
C. | both a and b |
D. | None of the above |
Answer» D. None of the above | |
9. |
Which is true about what getc returns? |
A. | The next character from the stream referred to by file pointer |
B. | EOF for end of file or error |
C. | Both a & b |
D. | Nothing |
Answer» D. Nothing | |
10. |
stderr, stdin, stdout are FILE pointers. |
A. | Yes |
B. | No |
C. | May Be |
D. | Can't Say |
Answer» B. No | |
11. |
EOF is an integer type defined in stdio.h and has a value ____________ |
A. | 1 |
B. | 0 |
C. | |
D. | -1 |
Answer» E. | |
12. |
Select a function which is used to write a string to a file. |
A. | pits() |
B. | putc() |
C. | fputs() |
D. | fgets() |
Answer» D. fgets() | |
13. |
We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind(). |
A. | True |
B. | False |
C. | May be True or False |
D. | Can't Say |
Answer» B. False | |
14. |
fseek() should be preferred over rewind() mainly because |
A. | rewind() doesn't work for empty files |
B. | rewind() may fail for large files |
C. | In rewind, there is no way to check if the operations completed successfully |
D. | All of the above |
Answer» D. All of the above | |
15. |
FILE reserved word is? |
A. | A structure tag declared in stdio.h |
B. | One of the basic datatypes in c |
C. | Pointer to the structure defined in stdio.h |
D. | It is a type name defined in stdio.h |
Answer» E. | |
16. |
Which of the following true about FILE *fp? |
A. | FILE is a keyword in C for representing files and fp is a variable of FILE type. |
B. | FILE is a stream |
C. | FILE is a buffered stream |
D. | FILE is a structure and fp is a pointer to the structure of FILE type |
Answer» E. | |
17. |
The first and second arguments of fopen() are |
A. | A character string containing the name of the file & the second argument is the mode |
B. | A character string containing the name of the user & the second argument is the mode |
C. | A character string containing file pointer & the second argument is the mode |
D. | None of the mentioned |
Answer» B. A character string containing the name of the user & the second argument is the mode | |
18. |
When fopen() is not able to open a file, it returns |
A. | EOF |
B. | |
C. | Run-time Error |
D. | None of the above |
Answer» C. Run-time Error | |
19. |
It is not possible to combine two or more file opening mode in open () method. |
A. | True |
B. | False |
C. | May be True or False |
D. | Can't Say |
Answer» C. May be True or False | |
20. |
Which files will get closed through the fclose() in the following program? |
A. | a, b |
B. | a |
C. | b |
D. | Error in fclose |
Answer» E. | |
21. |
What is the purpose of "rb" in fopen() function used below in the code? |
A. | Open "demo.txt" in binary mode for reading |
B. | Create a new file "demo.txt" for reading and writing |
C. | Open "demo.txt" in binary mode for reading and writing |
D. | None of the above |
Answer» B. Create a new file "demo.txt" for reading and writing | |
22. |
If there is any error while opening a file, fopen will return? |
A. | Nothing |
B. | EOF |
C. | |
D. | Depends on compiler |
Answer» D. Depends on compiler | |