2

Looking at this code:

enter image description here

I thought that the program won't give the right maximal value if z>x and y>x, but, to my surprise, it did give the correct value. Why is that? Did the program compare Y and Z and gave the biggest value without me ordering it to do so?

Mureinik
  • 297,002
  • 52
  • 306
  • 350

2 Answers2

2

After the first if statement, max holds the maximum of x and y. This maximum is then compared with z in the second if statement. You don't need to compere y and z directly due to the transitive quality of the > operator.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

Knowing that (z > y) and (y > x) makes it certain that z > x, so you don't have to compare every value to assume that one of them is the maximum. Talking about Compiler i can suggest you Sublime as a good Compiler for object pascal all you have is to install FPC and add it on building packages or you can simply use MyPascal which is seemed very helpful as this one you're using seems old-fashioned.

MEDX
  • 89
  • 8