Quiz: Conditional Statements and Loops
Quiz: Conditional Statements and Loops checks how well you can apply if-else ladder for grade ranges and switch without break behavior (and related ideas) in C.
Introduction
Quiz: Conditional Statements and Loops checks how well you can apply if-else ladder for grade ranges and switch without break behavior (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: if-else ladder for grade ranges.
Challenge 2 In your own words — or with a tiny program — show that you understand: switch without break behavior.
Challenge 3 In your own words — or with a tiny program — show that you understand: while vs do-while difference.
Challenge 4 In your own words — or with a tiny program — show that you understand: Nested loop output pattern.
- Challenge 1 — In your own words — or with a tiny program — show that you understand: if-else ladder for grade ranges.
- Challenge 2 — In your own words — or with a tiny program — show that you understand: switch without break behavior.
- Challenge 3 — In your own words — or with a tiny program — show that you understand: while vs do-while difference.
- Challenge 4 — In your own words — or with a tiny program — show that you understand: Nested loop output pattern.
Step-by-step explanation
- Challenge 1 — In your own words — or with a tiny program — show that you understand: if-else ladder for grade ranges.
- Challenge 2 — In your own words — or with a tiny program — show that you understand: switch without break behavior.
- Challenge 3 — In your own words — or with a tiny program — show that you understand: while vs do-while difference.
- Challenge 4 — In your own words — or with a tiny program — show that you understand: Nested loop output pattern.
Execution workflow
Challenge 1
In your own words — or with a tiny program — show that you understand: if-else ladder for grade ranges.
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: if-else ladder for grade ranges
- Build or explain: switch without break behavior
- Build or explain: while vs do-while difference
- Build or explain: Nested loop output pattern
Summary
Quiz: Conditional Statements and Loops in C — Self-check on control flow.