Implementing User Defined Functions

Ceng198

Grading Lab #3

Sections 1 & 2

Define a function name “Calculator” that takes 3 parameters; first operand with data type float, second operand with data tye float and the operator with data type chratacter. The function should make a calculation according to the given character and then return the value calculated to main.

Sample Run:

Enter first operand: 5

Enter operator: +

Enter second operand: 3

The result is = 8

Sections 3 & 4

Define a function named “Conversion” that takes 2 parameters; a character to specify the conversion type (celcius or fahrenheit) and a float value that is going to be converted according to the specified conversion type. The function makes a conversion from celcius to fahrenheit or from fahrenheit to celcius.

Use the following equations when converting;

Fahrenheit = ((9/5) * Celcius) + 32

Celcius = (5/9) * (Fahrenheit - 32)