Just as we need variables to do interesting mathematics, we need them to
write interesting programs too.
Let's look at a simple example:
int i, j;
i = 5;
j = 3;
printf("sum = %d, product = %d\n", i + j, i * j);
Even this simple program illustrates a number of facets of variables and
Each variable has a type.
In this example the variables are declared to be of type int which stands
That is these variables may only hold whole numbers and not fractions.
Other variable types include float (for numbers with fractional parts)
and char (for holding single characters such as digits, letters and
More than one variable may be declared in the same statement.
Variables have names,
in this example.
Unlike mathematics, we normally use much longer variable names
for the number of students at some point in the program.
C allows only certain variable names (identifiers):
An identifier may be composed of letters, digits or the underscore
An identifier must start with a letter or an underscore.