C · Course navigation

C Variables

Declare typed values.

On this page

The concept

C variables have explicit types. int stores an integer, while double stores a floating point value. printf writes formatted output.

Code example

C
#include <stdio.h>
int main(void) {
  int score = 91;
  printf("%d\n", score);
  return 0;
}
Output
91

Follow the code

Open the walkthrough to inspect the example one step at a time.

Show guided walkthrough
Guided walkthroughReady
1#include <stdio.h>
2int main(void) {
3 int score = 91;
4 printf("%d\n", score);
5 return 0;
6}

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Allocate an int named score and initialize it to 91.score = 91
—
%d formats the integer; \n ends the line.score = 91
91
Return zero to signal successful completion.score = 91
91

Behind the scenes

How C processes this code

The C compiler produces a native program. Variables occupy memory, and execution enters main.