Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add a void function to the program. The void function will display the title bel

ID: 3533344 • Letter: A

Question

Add a void function to the program. The void function will display the title below before the Menu options.

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

(Program Must run correctly)


#include <iostream>

using namespace std;


double add(double num1,double num2)

{

return num1+num2;

}

double multiply(double num1,double num2)

{

return num1*num2;

}

int main()

{

int choice=0;

double num1,num2;

do

{

printf("1. Add 2. Multiply 3. Exit Enter an option: ");

scanf("%d",&choice);

if(choice==1||choice==2){

printf("Enter a number: ");

scanf("%lf",&num1);

printf("Enter another number: ");

scanf("%lf",&num2);

if(choice==1)

printf("The sum of %lg and %lg is %lg ",num1,num2,add(num1,num2));

if(choice==2)

printf("The product of %lg and %lg is %lg ",num1,num2,multiply(num1,num2));

}

}while(choice!=3);

return 0;

}

Explanation / Answer

#include <iostream>

using namespace std;

void display() {

printf("The Math Program");

}

double add(double num1,double num2)

{

return num1+num2;

}

double multiply(double num1,double num2)

{

return num1*num2;

}

int main()

{

int choice=0;

double num1,num2;

display();

do

{

printf("1. Add 2. Multiply 3. Exit Enter an option: ");

scanf("%d",&choice);

if(choice==1||choice==2){

printf("Enter a number: ");

scanf("%lf",&num1);

printf("Enter another number: ");

scanf("%lf",&num2);

if(choice==1)

printf("The sum of %lg and %lg is %lg ",num1,num2,add(num1,num2));

if(choice==2)

printf("The product of %lg and %lg is %lg ",num1,num2,multiply(num1,num2));

}

}while(choice!=3);

return 0;

}

output:

The Math Program

1. Add

2. Multiply

3. Exit

Enter an option:


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote