Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Day-13

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

What does this declaration mean?

a)

Creates a new file

b)

Declares a file pointer

c)

Opens a file for writing

d)

Closes the file

2.

Which function is used to open a file in C?

a)

open()

b)

file()

c)

fopen()

d)

start()

3.

Which mode opens a file for writing and overwrites existing content?

a)

"r"

b)

"a"

c)

"r+"

d)

"w"

4.

What does "a+" mode do?

a)

Opens file for reading and appending

b)

Deletes the content of file

c)

Opens file for writing and reading

d)

Opens file for appending only

5.

Which function is used to write a string to a file?

a)

fputs()

b)

fprintf()

c)

fputc()

d)

fwrite()

6.

What happens if the file you try to open in "r" mode doesn’t exist?

a)

It creates an empty file

b)

It returns NULL

c)

It gives a warning

d)

It creates the file

7.

What is the purpose of fclose(fp);?

a)

To close the file

b)

To free memory

c)

To flush the buffer

d)

All of the above

8.

Which function reads a single character from the file?

a)

getch()

b)

fgetc()

c)

getchar()

d)

getc()

9.

How can you check if the file opened successfully?

a)

fp == 1

b)

fp == EOF

c)

fp == NULL

d)

fp == 0

10.

Which mode creates a new file if it doesn’t exist and appends to the end if it does?

a)

"a"

b)

"r+"

c)

"w"

d)

"r"