a) The program randomly generates two "integers between 0 and 9 inclusive" (int1 and int2) and displays them. Request from the user to specify the mathematical operations (+,-,*, /). b) Use (switch) statement to calculate and print the results of the four mathematical operations (+,-,*, /) on the above two random numbers according to the choice of user. c) Answer the following questions: a. Rewrite the above code using ( if) statement instead of (switch) statement to do the same task in (b). b. What is the value of x after the following if-else statement is executed? Rewrite it using a switch statement. int x = 1, a = 3; if (a == 1) x += 5; else if (a == 2) x += 10; else if (a == 3) x += 16; else if (a == 4) x += 34;
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
a) The
b) Use (switch) statement to calculate and print the results of the four mathematical operations (+,-,*, /) on the above two random numbers according to the choice of user.
c) Answer the following questions:
a. Rewrite the above code using ( if) statement instead of (switch) statement to do the same task in (b).
b. What is the value of x after the following if-else statement is executed? Rewrite it using a switch statement.
int x = 1,
a = 3;
if (a == 1)
x += 5;
else if (a == 2)
x += 10;
else if (a == 3)
x += 16;
else if (a == 4)
x += 34;
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 5 steps with 13 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)