Skip to main content

Precedence of Operations. More Loops

  • Chapter
Mastering Pascal Programming

Part of the book series: Macmillan Master Series ((MACMMA))

  • 35 Accesses

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

$$ 2 + 3*4 $$

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

$$ 12 - 6DIV3 $$

will give 10 in Pascal, not 2.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

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)

Publish with us

Policies and ethics