

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Memory Management
incomplete
2: C Program Structure
incomplete
3: Interpreted Quiz
incomplete
4: C Is Compiled
incomplete
5: Comments
incomplete
6: Basic Types
incomplete
7: Strings
incomplete
8: Printing Variables
incomplete
9: Compilation: Types
incomplete
10: Variables
incomplete
11: Constants
incomplete
12: Functions
incomplete
13: Void
incomplete
14: Unit Tests
incomplete
15: Math Operators
incomplete
16: If Statements
incomplete
17: Logical Operators
incomplete
18: Ternary
incomplete
19: Type Sizes
incomplete
20: Sizeof
incomplete
21: For Loop
incomplete
22: While Loop
incomplete
23: Do While Loop
incomplete
24: Pragma Once and Header Guards
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
A while loop in C is a control flow statement that allows code to be executed repeatedly based on a given boolean (true/false) condition. The loop continues to execute as long as the condition remains true.
while (condition) {
// Loop Body
}
while Looptrue, execute the body. If false, terminate the loopcondition is true.#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
printf("%d\n", i);
i++;
}
return 0;
}
// Prints:
// 0
// 1
// 2
// 3
// 4
false initially, the loop body will never even start.false, you will get an infinite loop.Implement the print_numbers_reverse prototyped in exercise.h. It takes a starting number (higher) and an ending number (lower) and prints all the numbers in that range from highest to lowest inclusive (this time, using a while-loop).