-2

So for an example i have a real number let's say 17.4578 but i want to display it in pascal with only two digits after the point so it's 17.45. What do i write in my program?

Shawn
  • 47,241
  • 3
  • 26
  • 60
Aloulou123
  • 3
  • 1
  • 6

3 Answers3

1
Write(17.4578:0:2)

Will display number 17.46
Generally, arguments look like this → Value : field_width : decimal_field_width
For more info click here

1

This would work. However, if this is the last line of code always remember a readln at the end.

    Writeln(17.4578:0:2) 

This would lead to 17.46 because it rounds up as it is followed by a 7.

Hope this helps

Dajan3
  • 23
  • 5
0

Use :0:2 at the end of Real number:

writeln(17.4578:0:2)
Metris Sovian
  • 254
  • 4
  • 20