Abstract
In Chapter 2 we listed some of the arithmetical operators which are used in Pascal. They can apply to both constants and variables and some of them (+, −, *) are applicable to constants and variables of type real or of type integer while others are restricted to type real (/) or to type integer (DIV, MOD). Pascal, in common with most other high level languages, awards precedence to multiplication and division operations over those of addition and subtraction. Those with higher precedence are all performed before those with lower precedence. These rules (and one or two others which we shall meet later) are very simple but, as they are different from those of many pocket calculators, they can be a bit confusing at first. For example
gives 14 in Pascal since the multiplication takes precedence and will be performed before the addition. On many pocket calculators the result would have been 20. Similarly
will give 10 in Pascal, not 2.
Preview
Unable to display preview. Download preview PDF.
Copyright information
© 1983 Eric Huggins
About this chapter
Cite this chapter
Huggins, E. (1983). Precedence of Operations. More Loops. In: Mastering Pascal Programming. Macmillan Master Series. Palgrave, London. https://doi.org/10.1007/978-1-349-17182-8_4
Download citation
DOI: https://doi.org/10.1007/978-1-349-17182-8_4
Publisher Name: Palgrave, London
Print ISBN: 978-0-333-32294-9
Online ISBN: 978-1-349-17182-8
eBook Packages: Computer ScienceComputer Science (R0)