System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 7
Q221:
______ provides cross-platform compatibility for file I/O operations.
A. Standard C/C++ functions
B. Windows DLLs
C. Visual Basic
D. Console scripts
Correct Answer:
A
Chapter: 7
Q222:
To access Windows-specific features, ______ should be used.
A. Standard Library
B. Windows APIs
C. OS Kernel
D. Batch files
Correct Answer:
B
Chapter: 7
Q223:
fopen(), fread(), fwrite(), and fclose() are functions used for ______ operations in C.
A. graphics
B. memory
C. file
D. network
Correct Answer:
C
Chapter: 8
Q224:
Which function is used to open a file in binary read mode in C?
A. open()
B. fopen()
C. fread()
D. fwrite()
Correct Answer:
B
Chapter: 8
Q225:
The function used to read data from a file in C is ______.
A. fwrite()
B. printf()
C. fread()
D. open()
Correct Answer:
C
Chapter: 8
Q226:
To write data to a file in C, we use
A. recv()
B. fwrite()
C. fprintf()
D. fcopy()
Correct Answer:
B
Chapter: 8
Q227:
Which buffer size is used in the example file copy program?
A. 512 bytes
B. 128 bytes
C. 256 bytes
D. 1024 bytes
Correct Answer:
C
Chapter: 8
Q228:
The C macro used to define buffer size in the program is
A. #size
B. #define
C. #include
D. #macro
Correct Answer:
B
Chapter: 8
Q229:
If a file fails to open, which function is used to print an error message?
A. perror()
B. printf()
C. fprintf()
D. errorlog()
Correct Answer:
A
Chapter: 8
Q230:
How many command-line arguments must be passed to run the program correctly?
A. 1
B. 2
C. 3
D. 4
Correct Answer:
C
Chapter: 8
Q231:
Which function is used to close a file in C?
A. endfile()
B. fclose()
C. closefile()
D. shutdown()
Correct Answer:
B
Chapter: 8
Q232:
The files are opened in ______ modes respectively for reading and writing.
A. text and binary
B. binary and text
C. text and text
D. binary and binary
Correct Answer:
D
Chapter: 8
Q233:
The main data structure used to hold the read content is
A. a string
B. an array of structs
C. a buffer
D. array of integers
Correct Answer:
C
Chapter: 8
Q234:
If fwrite does not write all bytes that were read, the program will
A. print an error and continue silently
B. ignore it and exit normally
C. print a fatal write error and return 4
D. reboot the system
Correct Answer:
C
Chapter: 8
Q235:
The fread() function reads the file in chunks of
A. 256 characters
B. 1 byte
C. 256 bytes
D. 512 bytes
Correct Answer:
C
Chapter: 8
Q236:
The file copy program checks for command-line arguments to avoid
A. segmentation fault
B. syntax error
C. usage error
D. linker error
Correct Answer:
C
Chapter: 8
Q237:
Which header file is necessary for file I/O functions like fopen()?
A. <string.h>
B. <conio.h>
C. <stdio.h>
D. <math.h>
Correct Answer:
C
Chapter: 8
Q238:
Which standard function displays the usage message when arguments are incorrect?
A. print()
B. warn()
C. usage()
D. printf()
Correct Answer:
D
Chapter: 8
Q239:
The loop continues to copy the file until
A. fread returns 0
B. bytesIn equals BUF_SIZE
C. all data is printed
D. fclose is called
Correct Answer:
A
Chapter: 8
Q240:
If fwrite fails during file copy, the return value is set to
A. 1
B. 2
C. 4
D. 3
Correct Answer:
C