Question: Lab U12 -- Some Programming Practice (20 pts) -- due the end of Unit 1 The objectives of this lab exercise are to: 1. Make

Lab U12 -- Some Programming Practice (20 pts) -- due the end of Unit 1

The objectives of this lab exercise are to:

1. Make sure you understand the concept of operator precedence in C++

expressions and statements.

2. Take simple problem descriptions and produce small but complete C++

programs that solve these problems.

3. Give you some practice in using simple C++ interactive input and output

capabilities.

4. Give you some practice in the simplest decision statement (if).

Specifications:

This is a four-part exercise (a-d).

a. For the three assignment statements listed below, label the operators according to the order

they will be evaluated, i.e., label the first evaluated operator with a 1, the second with a 2, and

so on (see pages 57 and 58 of your text for examples of how to do this). Then fill in the blank

with the result assigned to variable x in each part.

i. x = 7 + 3 * 6 / 2 1;

x = ________

ii. x = 2 % 2 + 2 * 2 2 / 2;

x = ________

iii. x = ( 3 * 9 * ( 3 + ( 9 * 3 / 3 ) ) );

x = ________

b. Write a C++ program that inputs three (3) integers from the keyboard and prints the sum,

average, product, smallest and largest of these numbers. For this exercise you may assume the

user does NOT enter any duplicate values. The interactive screen dialogue should look

something like this (user input is shown in bold):

Input three different integers separated by spaces: 13 27 14

Sum is 54

Average is 18

Product is 4914

Smallest is 13

Largest is 27

c. Write a C++ program that reads in the radius of a circle and prints the circles diameter,

circumference, and area. Declare and use the constant 3.1415926 for p. Do the calculations

for diameter, circumference and area in the output statements (HINT: this means you do

NOT need variables for holding your calculated values of diameter, circumference, or

area).

For 5 points extra credit: determine the volume of a sphere using the radius. Note on

your lab that you implemented this extra credit option.

d. Write a C++ program that reads an integer and determines and prints whether it is odd or

even. (Hint: Use the modulus operator (%). An even number is a multiple of 2 and any

multiple of 2 leaves a remainder of zero (0) when divided by 2).

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!