0% found this document useful (0 votes)
9 views4 pages

C Functions Chapter5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

C Functions Chapter5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

C Programming - Chapter 5: Functions Test Paper

------------------------------------------------------------

Section 1: Multiple-Choice Questions (20 Marks)

1. Which of the following statements about functions in C is true?

A) Functions can return multiple values

B) Functions cannot return a value

C) Functions can be called recursively

D) Functions must always return an int

2. What is the purpose of a function prototype?

A) To allocate memory for the function

B) To define the function's behavior

C) To declare the functions signature before use

D) To store function variables

3. Which of the following is NOT a valid function declaration in C?

A) int func();

B) void func(int a, int b);

C) float func(float, float);

D) func(int, int);

4. Which keyword is used to prevent modifications to function arguments?

A) const B) static C) extern D) volatile


5. What is the default return type of a C function if not specified?

A) int B) void C) char D) float

------------------------------------------------------------

Section 2: Fill in the Blanks (10 Marks)

1. A function declared with the _______ keyword cannot be modified.

2. _______ functions are called automatically when an object is created.

3. Recursion involves a function calling _______.

4. Functions defined outside all functions are called _______ functions.

5. The _______ keyword is used for optional function arguments.

------------------------------------------------------------

Section 3: True/False (10 Marks)

1. A function in C can return multiple values. (True/False)

2. Recursion can lead to stack overflow if not controlled. (True/False)

3. Function prototypes are mandatory in C. (True/False)

4. Static functions can be accessed from other files. (True/False)

5. Inline functions guarantee no overhead. (True/False)

------------------------------------------------------------

Section 4: Short Answer Questions (20 Marks)

1. Explain function overloading. Is it supported in C?

2. What is the difference between call by value and call by reference?

3. How does recursion work? Explain with an example.

4. What is a function pointer and why is it useful?

5. Write a function prototype for a function that returns a float and takes two int arguments.
------------------------------------------------------------

Section 5: Code Analysis & Output Prediction (20 Marks)

1. Predict the output of the following code:

#include <stdio.h>

void func(int n) {

if (n > 0) {

printf("%d ", n);

func(n - 1);

int main() {

func(5);

return 0;

2. What will be the output of this code?

#include <stdio.h>

int sum(int a, int b) {

return a + b;

int main() {
int (*ptr)(int, int) = sum;

printf("%d", ptr(4, 6));

return 0;

------------------------------------------------------------

Section 6: Programming Problems (20 Marks)

1. Write a recursive function in C to calculate the factorial of a number.

2. Create a C program that uses a function pointer to perform arithmetic operations (addition, subtraction, m

------------------------------------------------------------

End of Paper

You might also like