LearnFrenzy
Sign in Take a free test

Functions · Exercise 1 of 4

Functions Function Basics MCQ

  • 12 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on prototypes, pass by value, static, recursion, inline functions and what C99 and C23 changed. Pick an option to check your answer instantly.

Question 1 Easy

How does C pass arguments to a function?

A By reference
B By value – the function gets copies
C By name
D Ints by value, everything else by reference
Question page & discussion
Question 2 Hard

In C23, what does the declaration int f(); mean?

A f takes any number of arguments
B f takes no parameters – the same as int f(void)
C f's parameters are unspecified, as in C89
D It is a syntax error
Question page & discussion
Question 3 Easy

What is the main purpose of a function prototype?

A To allocate memory for the function
B To let the compiler check the number and types of arguments in each call
C To make the function run faster
D To make the function private
Question page & discussion
Question 4 Easy

Which is true about static int count = 0; declared inside a function?

A It is reset to 0 on every call
B It is initialised once and keeps its value between calls
C It can be used from any file
D It is stored on the stack
Question page & discussion
Question 5 Medium

What does static do when written before a function definition at file level?

A The function keeps its local variables between calls
B The function can only be called from the same source file
C The function is inlined
D The function runs once
Question page & discussion
Question 6 Medium

In which order are the arguments of f(a(), b()) evaluated?

A Left to right
B Right to left
C Unspecified – the compiler may choose
D Both at the same time
Question page & discussion
Question 7 Medium

What happens with a definition like add(int a, int b) { return a + b; } in C99 and later?

A The return type defaults to int
B The return type defaults to void
C It is invalid: implicit int was removed in C99
D The return type is inferred from the return statement
Question page & discussion
Question 8 Easy

Which statement about recursion in C is true?

A All recursive calls share one set of local variables
B Each call gets its own stack frame, so very deep recursion can overflow the stack
C C turns every recursion into a loop
D A recursive function cannot return a value
Question page & discussion
Question 9 Medium

Which is true about returning an array from a function?

A int f(void)[10] returns an array of 10 ints
B A function cannot return an array, but it can return a struct that contains one
C Returning a local array is fine
D Arrays are always returned by reference
Question page & discussion
Question 10 Medium

What does inline mean for a C function?

A The compiler must copy the body into every call
B It is a hint; the compiler may or may not expand the calls in place
C The function is executed at compile time
D The function becomes a macro
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links