Lab 4

In this week's lab you must write a C program to develope a calculator using functions. You will need to know simple input/output, declaring variables, if statements,operations,loops, and how to write and utilize functions(passing the value and returning the value).

The execution of the finished program should look like what is shown below.

Welcome to the calculator.

Your current value is 0

Options are:

1. Add

2. Subtract

3. Multiply

4. Divide

9. Exit

Please enter an operation -> 1

Please enter the number to be added -> 4

Your current value is 4

Options are:

1. Add

2. Subtract

3. Multiply

4. Divide

9. Exit

Please enter an operation -> 4

Please enter the number to be divided -> 3

Your current value is 1

Options are:

1. Add

2. Subtract

3. Multiply

4. Divide

9. Exit

Please enter an operation -> 9

Your final value is 1. Exiting program...

The difference from last week's lab is that we want you to use functions for each of the operations. There should be no mathematical operations in main besides the assignment statement, all of the operations must be performed in separate functions outside main.

          Take the user input and set the current value 0. Declare the functions for all the operations. Use switch case to define the menu options.

 It should ask once what operation to perform on the initial value of 0, and then based on that input perform that operation, print out the result, then "loop back" and ask the user what operation they would like to perform next. As a starting point use the sample file provided.

 Add a menu option to display the currently stored number in binary. Assume the number is 0..255, which should give output of 8 bits.

Notes:

Submission: