ConceptStep · learning platform for computer science

Variables and assignment

C programming · Lesson

C · lesson 3 / 27

Variables and assignment

Track x while two flowchart blocks correspond to two C assignments.

1 · Observe and predict

The concept

The right-hand side is evaluated first, then the new value replaces the variable's current value.

Mental model:

x = 4 → compute x + 3 → store x again → output

2 · Flowchart First

Follow the same algorithm as a flowchart

Use Start and Step: when the active block changes, ConceptStep also highlights the C lines representing that same step.

Loading flowchart…
3 · Flowchart ↔ C · Run in Page

Lab 1 — Run the example program

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.

Variables and assignment Start the flowchart to synchronize the code
                        1#include <stdio.h>
                        2 
                        3int main(void)
                        4{
                        5    int x = 4;
                        6    x = x + 3;
                        7    printf("%d\n", x);
                        8    return 0;
                        9}
Ready. Make a prediction before running.

                    
                

Lab 2 — Coding challenge: write your code — Successive assignments

Read x; add 4, then double and print x.

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.

4 · Guided practice

Check your prediction

After x = 4 and x = x + 3, what is x?

Challenge 1 / 5 · Understanding

Progress: 0 / 5 · correct: 0

Your competency map

What you need to know for Variables and assignment

ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.

Current topic Strong skill Review due Needs reinforcement To be mastered Optional support

Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.

GUIDED LEARNING PATHS

Want to choose the next skill to develop?