Unit 4: Functions - Subjective Questions

CAP1008 — C Programming • Practice Questions with Detailed Answers

20 questions

1

Define a function in C. Explain the general syntax of a function definition with a suitable example.

2

Distinguish between predefined (library) functions and user-defined functions with examples.

3

Explain the scope rules in C. Differentiate between local scope and global scope with examples.

4

What is a pointer? Explain pointer declaration and initialization with examples.

5

Explain how values are accessed using pointers. Describe the role of the dereference operator with an example.

6

Distinguish between call by value and call by reference (address) in C with suitable examples.

7

What is recursion? Explain with an example program to calculate the factorial of a number.

8

Describe the components of a function in C: function declaration (prototype), function definition, and function call.

9

Explain the advantages of using functions in C programming.

10

What are library functions? Explain commonly used library functions from stdio.h, math.h, and string.h.

11

Write a C program using a user-defined function to check whether a given number is prime. Explain its working.

12

Explain the concept of passing arguments by address to swap two numbers. Write the complete program.

13

Compare recursion and iteration. State the advantages and disadvantages of each.

14

Explain the different categories of functions based on arguments and return values with examples.

15

Write a recursive C program to generate the Fibonacci series up to terms and explain the logic.

16

Explain the relationship between pointers and arrays in C with an example.

17

What is a NULL pointer and a wild pointer? Explain their significance in C programming.

18

Explain storage classes in C (auto, register, static, extern) and their effect on scope and lifetime.

19

Describe how a function returns a value. Write a program using a function that returns the largest of three numbers.

20

Explain the advantages and disadvantages of using pointers in C programming.