Skip to Main Content
C Programming: Visual Quickstart Guide
book

C Programming: Visual Quickstart Guide

by Larry Ullman, Marc Liyanage
October 2004
Beginner content levelBeginner
408 pages
9h 24m
English
Peachpit Press
Content preview from C Programming: Visual Quickstart Guide

Understanding Precedence

As you were probably taught when you first learned arithmetic, operators have a precedence: rules dictating in what order calculations are made. These are important to understand because they can dramatically affect the end result.

Table 3.2 lists the order of precedence in C for the arithmetic operators, but it's probably easiest just to follow these three rules:

1.
Multiplication and division take place before addition and subtraction.
2.
Operators with the same precedence level are executed from left to right.
3.
Use parentheses to guarantee your results.
Table 3.2. The precedence of operators from highest to lowest (those listed first will be executed first).
Rules of Precedence
Operator
()
++, --
+, - (Sign operators) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intermediate C Programming

Intermediate C Programming

Yung-Hsiang Lu
Data Structures Using C

Data Structures Using C

Samir Kumar Bandyopadhyay, Kashi Nath Dey

Publisher Resources

ISBN: 0321287630Purchase book