WorksheetsC Programming Functions Quiz
Total questions: 15
Worksheet time: 8mins
Which keyword is used to define a function in C?
def
function
void
None of the above
Where should a function prototype usually be written?
Inside main()
In header files or before main()
At the end of the program
In a loop
What does a function prototype specify?
Function definition
Return type + name + parameters
Variable size
None
Which of the following is a valid function declaration?
add(a,b);
int add(int, int);
add(int a, int b);
int add(a b);
What is the default return type of functions in C (old ANSI C)?
void
int
float
char
Header files in C usually have which extension?
.c
.exe
.h
.txt
Which header file is used to handle input and output in C?
string.h
stdio.h
math.h
stdlib.h
What happens if you use a function without including its header or prototype?
Compile error
Runtime error
Implicit declaration warning / undefined behaviour
Nothing
What is the purpose of a header file?
To define variables
To store function prototypes and declarations
To execute code
To store loops
Which of the following is NOT a built-in C header file?
stdio.h
math.h
myheader.h
stdlib.h
Which part of the function specifies what value it sends back?
Parameters
Return type
Function name
Body of function
What is the correct syntax to call a function?
call function add();
add;
add();
function add();
What happens when a function does not have a return statement, but its return type is non-void?
It returns garbage value
It returns 0
It crashes
Compile-time error always
Which keyword is used to include header files?
import
use
include
#include
Which header file provides mathematical functions like sqrt(), pow()?
stdlib.h
math.h
string.h
stdio.h
