A.4. FUNDAMENTAL PROGRAMMING CONCEPTS 371
for accurate and predictable results. The modiﬁer “unsigned” indicates all bits will be used to specify
the magnitude of the argument. Signed variables will use the left most bit to indicate the polarity
(±) of the argument.
A global variable is declared using the following format provided below. The type of the
variable is speciﬁed, followed by its name, and an initial value if desired.
unsigned int loop_iterations = 6;
A.3.6 MAIN PROGRAM
The main program is the hub of activity for the entire program.The main program typically consists
of program steps and function calls to initialize the processor, followed by program steps to collect
data from the environment external to the microcontroller, process the data and make decisions, and
provide external control signals back to the environment based on the data collected.
A.4 FUNDAMENTAL PROGRAMMING CONCEPTS
In the previous section, we covered many fundamental concepts. In this section, we discuss operators,
programming constructs, and decision processing constructs to complete our fundamental overview
of programming concepts.
There are a wide variety of operators provided in the C language. An abbreviated list of common
operators are provided in Figures A.5 and A.6.The operators have been grouped by general category.
The symbol, precedence,and brief description of each operator are provided.The precedence column
indicates the priority of the operator in a program statement containing multiple operators. Only
the fundamental operators are provided. For more information on this topic, see Barrett and Pack
in the Reference section at the end of the chapter.
A.4.1.1 General operations
Within the general operations category are brackets, parenthesis, and the assignment operator. We
have seen in an earlier example how bracket pairs are used to indicate the beginning and end of the
main program or a function. They are also used to group statements in programming constructs and
decision processing constructs. This is discussed in the next several sections.
The parenthesis is used to boost the priority of an operator. For example, in the mathematical
expression 7 x 3 + 10, the multiplication operation is performed before the addition since it has
a higher precedence. Parenthesis may be used to boost the precedence of the addition operation. If
we contain the addition operation within parenthesis 7 x(3 + 10), the addition will be performed
before the multiplication operation and yield a different result from the earlier expression.