C/C++ Arena

Step 1 of 6

Your first variable

A variable is a named box that holds a value. In C you must say what type of value goes in the box.

int kills = 25;

This creates a box named kills that holds an int (a whole number) and puts 25 in it.

To print it, printf needs a format specifier where the value should go. For an int that's %d:

printf("Kills: %d\n", kills);

Your turn: declare an int named score with the value 42.

Next: Printing values with %d