Quiz: Functions
Quiz: Functions checks how well you can apply Function prototype purpose and Return type void (and related ideas) in C.
Introduction
Quiz: Functions checks how well you can apply Function prototype purpose and Return type void (and related ideas) in C. Try each prompt in a scratch file before moving on.
Understanding the topic
Challenge 1 In your own words — or with a tiny program — show that you understand: Function prototype purpose.
Challenge 2 In your own words — or with a tiny program — show that you understand: Return type void.
Challenge 3 In your own words — or with a tiny program — show that you understand: Recursion base case.
Challenge 4 In your own words — or with a tiny program — show that you understand: Scope of local variables.
- Challenge 1 — In your own words — or with a tiny program — show that you understand: Function prototype purpose.
- Challenge 2 — In your own words — or with a tiny program — show that you understand: Return type void.
- Challenge 3 — In your own words — or with a tiny program — show that you understand: Recursion base case.
- Challenge 4 — In your own words — or with a tiny program — show that you understand: Scope of local variables.
Step-by-step explanation
- Challenge 1 — In your own words — or with a tiny program — show that you understand: Function prototype purpose.
- Challenge 2 — In your own words — or with a tiny program — show that you understand: Return type void.
- Challenge 3 — In your own words — or with a tiny program — show that you understand: Recursion base case.
- Challenge 4 — In your own words — or with a tiny program — show that you understand: Scope of local variables.
Execution workflow
Challenge 1
In your own words — or with a tiny program — show that you understand: Function prototype purpose.
Best practices
- Enable warnings: gcc -Wall -Wextra -std=c11 source.c -o app
- Give every variable a defined value before it is read.
- Stay inside array bounds — C will not stop you from over-running a buffer.
Common mistakes
- Reading uninitialized storage — behavior is undefined.
- Dismissing compiler warnings instead of fixing root causes.
- Ignoring NULL returns from malloc, fopen, and similar APIs.
Hands-on exercise
Practice problems:
- Build or explain: Function prototype purpose
- Build or explain: Return type void
- Build or explain: Recursion base case
- Build or explain: Scope of local variables
Summary
Quiz: Functions in C — Self-check on prototypes, scope, and recursion.