COMP 122 DeVry Week 1 Homework Latest

Downloading is very simple, you can download this Course here:

http://wiseamerican.us/product/comp-122-devry-week-1-homework-latest/

Or

Contact us at:

SUPPORT@WISEAMERICAN.US

COMP 122 DeVry Week 1 Homework Latest

COMP122

COMP 122 DeVry Week 1 Homework Latest

Part 1: Complete the following problems.

  1. What is machine code? Why is it preferable to write programs in a high level language such as C++?
  2. What does a compiler do? What kinds of errors are reported by a compiler?
  3. What does the linker do? 4. What is an algorithm?
  4. Bob enters a pizza shop and notices there are three different sizes of pizzas available. Sizes are given as the diameter of the pizza in inches. The cost of a pizza is based on the size. Bob would like to know which size of pizza has the lowest cost per square inch.
  5. Identify the inputs and outputs for this problem.
  6. Identify the processing needed to convert the inputs to the outputs.
  7. Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output.

 

Part 2: Complete the following problems.

  1. Given the following expressions, what value would they have in a C++ program?
  2. 13 / 4
  3. 2 + 12 / 4
  4. 21 % 5
  5. 3 – 5 % 7
  6. 17.0 / 4
  7. 8 – 5 * 2.0
  8. 14 + 5 % 2 – 3
  9. 15.0 + 3.0 / 2.0
  10. Given the following variable declarations:

int num1 = 10, num2 = 20, newNum = 30;

double x = 5.0, y = 8.0;

Determine which of the following assignment statements are valid. For each invalid statement, explain why it is invalid. Assume that each statement immediately follows the above variable declarations.

  1. num1 = 15;
  2. num2 = num1 – 18;
  3. num1 = 5; num2 = 2 + 6; num1 = num2 / 3;
  4. num1 + num2 = newNum;
  5. x = 12 * num1 – 15.3;
  6. num1 * 2 = newNum;
  7. x / y = x * y;
  8. num2 = num1 % 2.0;
  9. newNum = static_cast (x) % 5;
  10. x = x + 5;
  11. newNum = num1 + static_cast (4.6 / 2);
  12. For each of the following lines of variable declarations, identify it as valid or describe what makes the line invalid.

Line 1: n = 12;

Line 2: char letter = ;

Line 3: int one = 5, two;

Line 4: double x, y, z;

  1. Write C++ statements that accomplish each of the following:
  2. Declare and initialize int variables x to 25 and y to 18.
  3. Declare and initialize an int variable temp to 10 and a char variable ch to ‘A’.
  4. Add 5 to the int variable x which already exists.
  5. Declare and initialize a double variable payRate to 12.50.
  6. Copy the value from an existing int variable firstNum into an existing int variable tempNum.
  7. Swap the contents of existing int variables x and y. (Declare any new variables you need.)
  8. Output the contents of existing double variables x and y, and also output the value of the expression x + 12 / y – 8.
  9. Copy the value of an existing double variable z into an existing int variable x.
  10. Given the following variable declarations:

int x = 2, y = 5, z = 6;

What is the output from each of the following statements?

  1. cout << “x = ” << x << “, y = ” << y << “, z = ” << z << endl;
  2. cout << “x + y = ” << x + y << endl;
  3. cout << “Sum of ” << x << ” and ” << z << ” is ” << x + z << endl;
  4. cout << “z / x = ” << z / x << endl;
  5. cout << “2 times ” << x << ” = ” << 2 * x << endl;
  6. Given the following variable declarations:

int a = 5, b = 6, c;

What is the value of a, b, and c after each of the following statements executes? Assume that the statements execute in the sequence given.

  1. a = b++ + 3;
  2. c = 2 * a + ++b;
  3. b = 2 * ++c – a++;