When writing programs, we should avoid long, repetitive code. Procedures and functions help to keep our programs simple and short.
What is a procedure?
A set of iterated statements
A small section of code within a program which performs a task
A decision point in a program
Why are procedures used?
To make code more readable
To reduce repetition of code
To calculate values
Why are functions used?
To reduce repetition of code and to calculate a value
To make decisions
What is the difference between a procedure and a function?
A procedure produces a calculated result whereas a function performs a task
A procedure iterates code whereas a function is a decision point
A procedure performs a task whereas a function produces a calculated result
What statement is used to create a procedure or function?
What term is given to running a procedure or function?
What term is given to passing back of the value calculated in a function?
Which of the following is a procedure?
A section of code which converts Fahrenheit to Celsius
A section of code which calculates VAT on a selling price
A section of code which resets all variables to zero
Which of the following is a function?
A section of code which updates a display
Why is code indented in a procedure or a function?
To show that it belongs within the procedure or function
To make it more readable
To show that it should be iterated