In these tasks you have to use the skills learned in the previous exercises to create a new program based on the requirements below.
- Define four subroutines – add, subtract, multiply, divide that add multiply etc two numbers and return the result. Each should have two integer number arguments.
- The user is asked to input two numbers. These numbers will be passed as arguments into one of the subroutines.
- The user is asked to input 1 to add, 2 to subtract etc.
- If they input 1, call the ‘add’ subroutine, input 2 calls the ‘subtract’ subroutine etc
- Output the returned result as part of a sentence.
Help! My code doesn’t work
Make sure that you check for the following things:
- The subroutine name is identical everywhere it is used (capitals matter)
- The subroutine call is not indented inside the subroutine
- The subroutine is defined before it has been called