C Variables
Variables are used as holders of data values.
In C, variables are classified into different types:
- int: An integer variable can hold only an integer.
- float: A floating-point variable can hold only floating-point numbers.
- char: A character variable can hold a character only.
Variable Declaration
Variable declaration is the act of defining the name and type of a variable prior to its use in the program.
Syntax:
Rules for Naming Variables
We can name the variable anything provided that it complies with the rules below:
- A variable name should consist of letters, numbers, and underscores.
- A variable may not begin with a digit.
- A variable name cannot have any white space in it.