C Programming — Functions
C language from basics to advanced placement prep
100 Questions 10 Topics Take Test
Advertisement
Showing 91–100 of 100 questions in Functions
Q.91 Medium Functions
What is a recursive function?
A A function that calls itself directly or indirectly
B A function that calls another function
C A function that returns multiple values
D A function that has no parameters
Correct Answer:  A. A function that calls itself directly or indirectly
EXPLANATION

A recursive function is one that calls itself. It must have a base case to avoid infinite recursion.

Take Test
Q.92 Medium Functions
Which of the following function calls is valid?
int calculate(int a, float b, char c);
A calculate(5, 3.14, 'A');
B calculate(5);
C calculate(5, 3.14);
D calculate('A', 3.14, 5);
Correct Answer:  A. calculate(5, 3.14, 'A');
EXPLANATION

All three parameters must be provided in correct order and compatible types.

Take Test
Q.93 Medium Functions
What happens if a function does not have a return statement?
A Compilation error occurs
B Runtime error occurs
C An undefined/garbage value is returned
D 0 is returned by default
Correct Answer:  C. An undefined/garbage value is returned
EXPLANATION

If a function with a non-void return type lacks a return statement, it returns undefined/garbage value. For void functions, no return is needed.

Take Test
Q.94 Medium Functions
What is the difference between function declaration and function definition?
A Declaration provides the function prototype; definition provides the actual implementation
B They are the same thing
C Declaration is mandatory; definition is optional
D Definition comes before declaration always
Correct Answer:  A. Declaration provides the function prototype; definition provides the actual implementation
EXPLANATION

Declaration (prototype) tells the compiler about the function signature; definition provides the actual function body and implementation.

Take Test
Q.95 Easy Functions
How many times can a function be called in a C program?
A Only once
B Maximum 10 times
C Unlimited times
D Maximum 100 times
Correct Answer:  C. Unlimited times
EXPLANATION

A function can be called as many times as needed within a program, limited only by memory and stack constraints.

Take Test
Q.96 Easy Functions
What will be the output of the following code?
int func(int x) { return x * 2; }
int main() { printf("%d", func(5)); }
A 5
B 10
C 20
D Error
Correct Answer:  B. 10
EXPLANATION

func(5) returns 5 * 2 = 10, which is then printed.

Take Test
Q.97 Easy Functions
Which of the following is a correct function declaration?
A int add(int a, int b);
B add int(a, b);
C int add a, b;
D add(int a, int b) int;
Correct Answer:  A. int add(int a, int b);
EXPLANATION

Function declaration syntax is: return_type function_name(parameter_list);

Take Test
Q.98 Medium Functions
What is the default return type of a function in C if not specified?
A void
B int
C float
D char
Correct Answer:  B. int
EXPLANATION

In older C standards (before C99), if no return type is specified, the default is 'int'. However, this is deprecated in modern C standards.

Take Test
Q.99 Easy Functions
Which keyword is used to define a function in C?
A function
B def
C No keyword needed, just return type and name
D func
Correct Answer:  C. No keyword needed, just return type and name
EXPLANATION

In C, functions are defined by specifying the return type followed by the function name and parameters. No specific 'function' keyword is used.

Take Test
Q.100 Easy Functions
What is the primary purpose of using functions in C programming?
A To modularize code and improve reusability
B To increase memory consumption
C To slow down program execution
D To eliminate the need for loops
Correct Answer:  A. To modularize code and improve reusability
EXPLANATION

Functions allow code reusability, modularity, and easier maintenance. They break down complex problems into smaller, manageable pieces.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips