Chapter 2 : Arithmetic in Pascal

QUICK REFERENCE
Useful Pascal arithmetic functions
Commonly used arithmetic functions
Pascal function Argument type Function type Function operation
sqrt(x) integer or real real returns the square root of x (x >= 0)
random(x) integer integer returns a random whole number between 0 and (x  -  1) inclusive
abs(x) integer or real same as argument returns the absolute value of x (i.e. |x|  )
round(x) integer or real integer returns the value of x rounded to the nearest integer
trunc(x) integer or real integer returns the integer formed by removing the fractional part of x
Other useful arithmetic functions
Pascal function Argument type Function type Function operation
sqr(x) integer or real same as argument returns the square of x, i.e. x2
sin(x) integer or real real returns the sine of x (in radians), i.e. sin x
cos(x) integer or real real returns the cosine of x (in radians), i.e. cos x
arctan(x) integer or real real returns the inverse tangent of x (result in radians), i.e. tan-1 x
ln(x) integer or real real returns the natural logirithm of x, i.e. ln x
exp(x) integer or real real returns the value of ex

EXERCISE
 Exercise
Description
Open
Download
Exercise 2-1
Rectangle
click here
ex2-1.pas
Exercise 2-2
Sell Disks
Exercise 2-3
Letter
Exercise 2-4
Circle
click here
ex2-4.pas
Exercise 2-5
Age