Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Functions Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which keyword is used to define a function in C?

a)

def

b)

function

c)

void

d)

None of the above

2.

Where should a function prototype usually be written?

a)

Inside main()

b)

In header files or before main()

c)

At the end of the program

d)

In a loop

3.

What does a function prototype specify?

a)

Function definition

b)

Return type + name + parameters

c)

Variable size

d)

None

4.

Which of the following is a valid function declaration?

a)

add(a,b);

b)

int add(int, int);

c)

add(int a, int b);

d)

int add(a b);

5.

What is the default return type of functions in C (old ANSI C)?

a)

void

b)

int

c)

float

d)

char

6.

Header files in C usually have which extension?

a)

.c

b)

.exe

c)

.h

d)

.txt

7.

Which header file is used to handle input and output in C?

a)

string.h

b)

stdio.h

c)

math.h

d)

stdlib.h

8.

What happens if you use a function without including its header or prototype?

a)

Compile error

b)

Runtime error

c)

Implicit declaration warning / undefined behaviour

d)

Nothing

9.

What is the purpose of a header file?

a)

To define variables

b)

To store function prototypes and declarations

c)

To execute code

d)

To store loops

10.

Which of the following is NOT a built-in C header file?

a)

stdio.h

b)

math.h

c)

myheader.h

d)

stdlib.h

11.

Which part of the function specifies what value it sends back?

a)

Parameters

b)

Return type

c)

Function name

d)

Body of function

12.

What is the correct syntax to call a function?

a)

call function add();

b)

add;

c)

add();

d)

function add();

13.

What happens when a function does not have a return statement, but its return type is non-void?

a)

It returns garbage value

b)

It returns 0

c)

It crashes

d)

Compile-time error always

14.

Which keyword is used to include header files?

a)

import

b)

use

c)

include

d)

#include

15.

Which header file provides mathematical functions like sqrt(), pow()?

a)

stdlib.h

b)

math.h

c)

string.h

d)

stdio.h