PROGRAMMING FOR PROBLEM SOLVING
Unit III · Functions and Program Structure
Understand functions, storage and recursion through direct answers, traces and tested programs.
Functions
- 01What is a user-defined function?2 marks
- 02Explain user-defined functions and their advantages.5 marks
- 03What is a function prototype?2 marks
- 04Distinguish a function declaration, definition and call with an example.5 marks
- 05List the four categories of functions based on arguments and return values.2 marks
- 06Explain the four categories of functions based on arguments and return values.5 marks
- 07Distinguish actual arguments and formal parameters.2 marks
- 08Explain actual arguments, formal parameters and communication between functions.5 marks
- 09What does return do in a function?2 marks
- 10Explain the return statement and return types in C functions.5 marks
Function Communication
Scope and Lifetime
Storage Classes
- 19What is the default storage duration of an ordinary block-local variable?2 marks
- 20Explain the auto storage class with an example.5 marks
- 21Does register guarantee that a variable is stored in a CPU register?2 marks
- 22Explain the register storage class and its restrictions.5 marks
- 23What happens to a local static variable between function calls?2 marks
- 24Explain local static variables and file-scope static declarations.5 marks
- 25What does extern int total; declare?2 marks
- 26Explain extern declarations with an example.5 marks
- 27Which two local storage classes have automatic storage duration?2 marks
- 28Compare auto, register, static and extern in C11.5 marks
Qualifiers and Preprocessor
- 29What does const mean for an object?2 marks
- 30Explain const, volatile and restrict type qualifiers.5 marks
- 31What is the purpose of the C preprocessor?2 marks
- 32Explain the C preprocessor and its main directives.5 marks
- 33Why should macro parameters be parenthesised?2 marks
- 34Explain object-like and function-like macros with precautions.5 marks
- 35Distinguish #if and an ordinary if statement.2 marks
- 36Explain conditional compilation and header guards.5 marks
Recursion
- 37What are the two essential parts of a terminating recursive solution?2 marks
- 38Explain recursion, its base case and recursive case.5 marks
- 39State the recursive definition of factorial.2 marks
- 40Write and explain a recursive C program to find factorial.5 marks
- 41State the base case in recursive Euclid’s GCD algorithm.2 marks
- 42Write a recursive C program to find the greatest common divisor using Euclid’s method.5 marks
- 43How do recursion and iteration repeat work?2 marks
- 44Compare recursion and iteration with reference to factorial.5 marks
No matching questions. Clear the search or change the marks filter.
The 2- and 5-mark badges are practice allocations. Previous-paper questions retain their printed marks.