Write a C++ program that involves switch statement and calling functions as foll
ID: 3647210 • Letter: W
Question
Write a C++ program that involves switch statement and calling functions as follows: Declare two float and one single character variables inside main. Inside main, pass two float variables to a function input() that will input the values of variables from a keyboard. Inside main input a single character variable from the keyboard. The allowed characters and their operation are shown in the "Character" table given below. Test the validity of these characters. If any other character is entered, then the user must re-enter until valid character is input. Inside main (), pass two input numbers and a single character to a function Show() for displaying. Inside main (), pass the single character to a "switch" statement that will do the operations shown in the table below by calling an appropriate function. Please make it sure to pass two numbers and character to a called function inside switch statement, and function must also display the result of operation performed on two numbers.Explanation / Answer
#include using namespace std; void input(float , float ); float add(float ,float); float sub(float ,float); float divison(float ,float); float multiplication(float ,float); int pow(int ,int); float a,b,z,x,y; int c,d,p=1; void input(float x, float y ) { x=a; y=b; } float add(float x, float y) { z=x+y; return z; } float sub(float x, float y) { z=x-y; return z; } float divide(float x, float y) { z=x/y; return z; } float multiply(float x, float y) { z=x*y; return z; } int pow(int c, int d) { while(d>0) { p=p*c; d--; } return p; } int main() { int o; for(o=0;oRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.