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;
Step by step
Solved in 5 steps with 13 images