C programming · Lesson
Follow a condition-controlled loop and observe how state changes toward termination.
while checks before each iteration; updating i lets the loop terminate.
i = 1 → while i <= limit → output i → i = i + 1 → test
Use Start and Step: when the active block changes, ConceptStep also highlights the C lines representing that same step.
Run C executes only the example shown on the left, using stdin on the right. The coding challenge below has a separate editor and test button.
1#include <stdio.h>
2
3int main(void)
4{
5 int limite;
6 scanf("%d", &limite);
7 int i = 1;
8
9 while (i <= limite)
10 {
11 printf("%d\n", i);
12 i = i + 1;
13 }
14
15 return 0;
16}
Read nonnegative N and print the sum from 1 to N using a loop.
This is a different program from lab 1. Complete the starter code: Check all test cases compiles this editor and tests every input, including boundary cases.
If limit = 4, how many iterations run?
Challenge 1 / 5 · Understanding
Progress: 0 / 5 · correct: 0
ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.
Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.