HOME LIBRARY C++ PHP JAVA HTML
CSAdeeb

Variables in C

Variables in C programming are the data storage names that are used to store data values during the program.

We learned that Constants in C remains unchanged during the execution of the program. But variables can have different values during the program execution. The Variables can change values dynamically.

Naming the Variables in C Language

The variable names are chosen by programmers. The recommended way to choose variable names is choosing meaningful names.

For example if we need a variable to store mark of a student, we can name the variable as student_mark or stud_mark etc.

Variable names are identifiers consist of letters, digits, and underscores. The five rules in naming identifiers in C programming should also be followed to name the variables.

  1. The first character must be an alphabet or underscore.
  2. Must consist of only letters, digits and underscore.
  3. Only the first 31 characters of an identifier are significant, others are ignored by the C compiler.
  4. A keyword cannot be used as an identifier.
  5. An identifier must not contain white spaces.

Examples for valid variable names: student_mark, mark1, stude_1 etc.

In the upcoming lessons we will learn declaring variables in C language.