There are 32 reserved words in C (also called
),which cannot be used as identifiers.The complete list of C keywords can be found in the reference textbook.Note that all keywords are written in lowercase letters.
Before a variable can be used in a program statement, it must be
int number;char c;float price;
To declare a variable means to specify its type, for example, integer, with a keyword
, (types of variables will be discussed later) and name. Variables of the same typecan be declared in one line.
int n1, n2, sum;
To assign a value to the variable, an assignment operator (
) is used, for example
number = 100;
. A variable can be
(that is, given an initial value) at thesame time as it is declared.
int number = 0;char c = 'a';float price = 2.5;
An expression is a combination of constants, variables, operators and functioncalls.
i + 8
is an expression of a constant plus a variable, and
isan expression of a function call. An expression can contain arithmetic and other typesof operators.
C arithmetic operators:
Remainder or modulusThe last operator in this list requires some explanation. The
isused to obtain the remainder of the division of the first operand by the secondoperand. For example,
7 % 3
8 % 4
5 % 7
The remainder operator can be applied only to
integer constants or variables