Learn C programming visually
Understand variables, for loops, arrays, functions and pointers with C examples and interactive traces.
Explore C lessons →Learn to code step by step with interactive visualizations, real code examples, quizzes and exercises in C, C++, Python, Java, JavaScript and C#.
Choose a programming language to compare code examples, or explore a beginner-friendly guide below.
A loop visits each value; a condition decides whether that value contributes to a result. Before running this Python example, predict how many scores meet the pass mark of 50.
scores = [42, 50, 73, 49]
passed = 0
for score in scores:
if score >= 50:
passed += 1
print(passed)
passed stays 0.>=, so the count becomes 1.2.passed += 1 counts a qualifying score; it does not add the score itself. Initializing the counter before the loop keeps the result from being reset on every iteration. The final print is outside the loop, so it reports one final count.
The output becomes 1: 50 no longer qualifies, leaving only 73. This is why a test exactly at the boundary is useful. With an empty list, the original program prints 0 because the loop body never runs.
Next, try [50], [49] and []. Predict each result before running it. In the Python counting workshop, turn this example into a function and test your predictions.
Prefer C? Step through a C loop, then see how a pointer lets a function update a caller's variable.
Choose C, C++, Python, Java, JavaScript, C#, or data structures. Follow a sequence of real lessons and save milestone progress privately on your device.
Read a beginner-friendly explanation, then open the interactive course to explore code and try the exercises.
Understand variables, for loops, arrays, functions and pointers with C examples and interactive traces.
Explore C lessons →Practice Python variables, conditions, loops and lists using step-by-step examples and visual demonstrations.
Explore Python lessons →See how arrays, stacks, queues, linked lists and other structures organize data.
Explore data structures →Explore individual interactive walkthroughs for loops, arrays, pointers and functions.
Trace the initialization, condition, body and update of a C for loop. Use Next and Previous to see exactly which values print and when the loop terminates.
Explore visual lesson →Choose an index, read its value and change it in a five-element C array. Learn why indexing starts at zero and why bounds matter.
Explore visual lesson →Watch a pointer store the address of an integer, read the integer using *p and update it through the pointer. Addresses shown are illustrative.
Explore visual lesson →Step through a function call from main to add and back again. See when parameters are created, how the return value is calculated and where execution resumes.
Explore visual lesson →