wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which function is used to open a file in C?

a)

fopen()

b)

fread()

c)

fclose()

d)

fprint()

2.

Which mode opens a file for reading only?

a)

"w"

b)

"r"

c)

"a"

d)

"r+"

3.

Which mode opens a file and clears old content?

a)

"a"

b)

"r"

c)

"w"

d)

"r+"

4.

Which function closes a file?

a)

fterminate()

b)

fclose()

c)

endfile()

d)

fstop()

5.

What does fgetc() do?

a)

Writes a character

b)

Reads a character

c)

Reads a string

d)

Closes a file

6.

Which function writes a string to a file?

a)

fputc()

b)

fgets()

c)

fputs()

d)

fprintf()

7.

What type does fopen() return?

a)

char pointer

b)

FILE pointer

c)

int

d)

void pointer

8.

Which file mode will append data at the end of file?

a)

"w"

b)

"a"

c)

"r"

d)

"r+"

9.

Which function is used to read a formatted input from file?

a)

scanf()

b)

fscanf()

c)

fread()

d)

gets()

10.

Which of the following is TRUE about binary files?

a)

They store characters only

b)

They store data as ASCII text

c)

They store raw bytes

d)

They cannot be read

11.

If fopen() fails to open a file, it returns:

a)

0

b)

NULL

c)

-1

d)

false

12.

Which function reads an entire line from a file?

a)

fgets()

b)

fgetc()

c)

fread()

d)

fscanf()

13.

To open a file for reading and writing without clearing existing data, use:

a)

"w+"

b)

"r"

c)

"a"

d)

"r+"

14.

What does ftell() return?

a)

The file name

b)

Total file size

c)

Current position of file pointer

d)

Number of lines

15.

Which function moves the file pointer to a specific location?

a)

ftell()

b)

fseek()

c)

fclose()

d)

remove()