Tutorials

C Tutorial

All Tutorials Learning Tools Login

C Tutorial · Chapter 6 of 16

C Variables

Store values that can change while the program runs.

Declare a variable with a type and a name, for example: int score = 90;

Choose clear names: score, age, and total are better than a, b, and x for beginners.

Variable sample Try it Yourself »
#include <stdio.h>

int main(void) {
    int age = 18;
    printf("Age: %d\n", age);
    return 0;
}

Classroom Tips

  • Initialize variables before using them.
  • Match the format specifier to the type.