COSC175 OPS HW – 25 points

Type in Word. Work with a partner and submit one copy per pair.

 

Partner 1: Name _______________________________

 

Partner 2: Name _______________________________

 

 

Please note if one partner did not work on all problems:

 

Give the value of x (x is an integer and assume integer arithmetic for all operations).

 

 

________  1.             x = 12 - 4 * 2 - 8;

 

________  2.             x = 24 / 2 + 1 * 4;

 

________  3.             x = 12 - 9 + 4 * 2 + 3 ^ 4;

 

________  4.             x = 24/(3 + 2) * 4;

 

________  5.             x = 2 * (5 - 3) + 7;

 

________  6.             x = 12 - (15/5 - 2) * 5;

 

________  7.             x = 20 - 15/((5 - 2) * 5);

 

________  8.             x = 13 % 5;

 

Evaluate the following equations, given A = 12, B = 3, C = 6, D = 2 ,A, B, C, and D are integers, and all operations are integer

 

________  9.             x = A + B/C - D^2.;

 

________  10.         x = A + B/(C - D^2);

 

________  11.         x = (A + B) % C;

 

________  12.         x = (A + B)/C - D^2;

 Assume the following order of operations:

!

&&

||

 

Give the value of x,

given A = FALSE, B = FALSE, C = FALSE, D = TRUE. E = 10, F = 15

 

________  13.         x = A && B

 

________  14.         x = C || D

 

________  15.         x = !C

 

________  16.         x = !(A && D)

 

________  17.         x = !C && B

 

________  18.         x = ( E < 10) && (E == F)

 

________  19.         x = A && B || C && D

 

________  20.         x = !(A && B) || !(D && C)

 

Write c++ statements for each of the following (no declarations necessary here):

  1. Output a message that says "Hello everybody"  

                                                                                   

  1. Prompt the user to enter a name.                      
  1. Input a name into a variable.                             
  2. Output Hello and the name you input.  
  3. Prompt for two numbers.                                 
  1. Input two numbers.                                          
  2. Compute the sum of the two numbers.  
  3. Output "the sum is" followed by the sum.          
  4. Modify the previous statement to echo print the two numbers entered. " the sum of x and y is z"; Do not use x, y, z use variables from above.

 

  1. Input the price of an item.                                 
  2. Calculate the sales tax.                         
  1. Compute the total price, given price and sales tax.

 

  1. Compute the average of three test scores.        

 

  1. Write code for the problems from HW1. Use the IPO’s that you previously created to help you. Show traces for 3 different sets of values. Trace 1 – known values, 2 and 3 – try unusual values, negatives, 0, etc. Make sure your program can handle all values. Indicate a potential problem with ***. We will learn how to make your program more robust soon.