WorksheetsC Programming Quiz
Total questions: 15
Worksheet time: 8mins
Which function is used to open a file in C?
fopen()
fread()
fclose()
fprint()
Which mode opens a file for reading only?
"w"
"r"
"a"
"r+"
Which mode opens a file and clears old content?
"a"
"r"
"w"
"r+"
Which function closes a file?
fterminate()
fclose()
endfile()
fstop()
What does fgetc() do?
Writes a character
Reads a character
Reads a string
Closes a file
Which function writes a string to a file?
fputc()
fgets()
fputs()
fprintf()
What type does fopen() return?
char pointer
FILE pointer
int
void pointer
Which file mode will append data at the end of file?
"w"
"a"
"r"
"r+"
Which function is used to read a formatted input from file?
scanf()
fscanf()
fread()
gets()
Which of the following is TRUE about binary files?
They store characters only
They store data as ASCII text
They store raw bytes
They cannot be read
If fopen() fails to open a file, it returns:
0
NULL
-1
false
Which function reads an entire line from a file?
fgets()
fgetc()
fread()
fscanf()
To open a file for reading and writing without clearing existing data, use:
"w+"
"r"
"a"
"r+"
What does ftell() return?
The file name
Total file size
Current position of file pointer
Number of lines
Which function moves the file pointer to a specific location?
ftell()
fseek()
fclose()
remove()
