Example 1 — Declare, assign, and update
Track a score as the program runs.
#include <stdio.h>
int main(void) {
int score = 10;
printf("start: %d\n", score);
score = score + 5;
printf("after bonus: %d\n", score);
score *= 2;
printf("doubled: %d\n", score);
return 0;
} How It Works
scoreis initialized to 10 when declared.score = score + 5reads the old value and stores the new one.score *= 2is shorthand forscore = score * 2.
