Question: 1. The Math Program (this is the title you want your void function to display) 1. Add 2. Multiply 3. Exit Here is my code

1.

The Math Program (this is the title you want your void function to display)

1. Add

2. Multiply

3. Exit

Here is my code :

using namespace std; // Function declarations double addition(double num1, double num2); double multiplication(double num1, double num2);

int main() { // Declaring variables int choice; double sum, multiply, product; double num1, num2;

// This loop continues to run until the user enters choice 3 while (true) { // Displaying the menu cout << " Menu" << endl; cout << "----" << endl; cout << "1. Add" << endl; cout << "2. Multiply" << endl; cout << "3. Exit" << endl; cout << "Enter choice :"; cin >> choice;

switch (choice) { case 1: {

cout << "Enter first number :"; cin >> num1; cout << "Enter second number :"; cin >> num2;

sum = addition(num1, num2);

// Displaying the sum of two numbers cout << "The sum of " << num1 << " and " << num2 << " is " << sum << endl; continue; } case 2: { // Getting the inputs numbers entered by the user cout << "Enter first number :"; cin >> num1; cout << "Enter second number :"; cin >> num2; product = multiplication(num1, num2);

// Displaying the product of two numbers cout << "The Product of " << num1 << " and " << num2 << " is " << product << endl; continue; } case 3: { cout << ":: Program Exit ::" << endl; break; } default: { cout << "Invalid input.Must be either 1 or 2 or 3" << endl;

continue; } } break; }

return 0; }

// Function implementation which add two numbers double addition(double num1, double num2) { return num1 + num2; } // Function implementation which multiplies two numbers double multiplication(double num1, double num2) { return num1 * num2; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!