You are on page 1of 3

Functions and procedures

• Write a procedure to
1. Calculate the area of a triangle. The procedure must receive the base and
height as parameters.
2. Calculate the area of a circle. The procedure must receive the radius as a
parameter. (use 22/7 or 0.1429 for Pi)
3. Solve a quadratic equation. The procedure must receive the coeffects of a, b
and c as parameters. (1,-3,-10  x1 = 5, x2 = -2 ) (3,2,-1  x1 = 1/3 , x2 = -1 )
4. Output the Fibonacci sequence from 1,1,2,3…55. The procedure must receive
initial values (previous =1 and current = 1) as parameters.

5. Create a menu which will display the 4 options (of the modules created above)
and ask a user to choose an option to run and then request for the relevant
parameters before calling the required module.
Functions and procedures
Menu

Select a procedure to run by pressing the corresponding


number
1. Calculate area of a triangle
2. Calculate Area of a circle
3. Solve a quadratic equation
4. Output a Fibonacci sequence
5. Exit the program
Functions and procedures
• Write a function to:
1. Calculate the area of a triangle. The procedure must receive the base and
height as parameters.
2. Calculate the area of a circle. The procedure must receive the radius as a
parameter. (use 22/7 or 0.1429 for Pi)
3. Solve a quadratic equations. The procedure must receive the coeffects of a, b
and c as parameters. (1,-3,-10  x1 = 5, x2 = -2 ) (3,2,-1  x1 = 1/3 , x2 = -1 )
(the functions must return the calculated values to the calling module which then
prints the values)

4. Create a menu which will display the 4 options (of the modules created above)
and as a user to choose an option to run and then request for the relevant
parameters before calling the required module.

You might also like