COMP122

Week 1 Homework

Portion 1: Complete the following concerns.

1 . What is machine code? Why is it much better write applications in a high level language just like C++?

2 . What does a compiler perform? What kinds of problems are reported by a compiler?

3. What does the linker perform?

4. What is an algorithm?

5. Greg enters a pizza shop and updates there are three different sizes of pizzas available. Sizes get as the diameter with the pizza in inches. The price of a pizza is based on the scale. Bob would like to know which will size of pizzas has the cheapest per square inch.

a. Identify the advices and outputs for this issue.

b. Determine the finalizing needed to convert the inputs to the outputs.

c. Design and style an algorithm in pseudocode to resolve this problem. Make sure to include steps to get each input and generate every output.

Component 2: Complete the following challenges.

1 . Given the following movement, what worth would they have in a C++ program?

a. 13 / 4

w. 2 & 12 / 4

c. 21 % 5

m. 3 - 5 % 7

at the. 17. zero / 4

f. almost 8 - five * installment payments on your 0

g. 14 + 5 % 2 -- 3

l. 15. 0 + three or more. 0 as well as 2 . 0

2 . Offered the following varying declarations:

int num1 sama dengan 10, num2 = twenty, newNum sama dengan 30;

double x = 5. 0, y = 8. zero;

Determine which of the pursuing assignment assertions are valid. For each unacceptable statement, explain why it is invalid. Assume that each affirmation immediately employs the above adjustable declarations.

a. num1 = 12-15;

b. num2 = num1 - 18;

c. num1 = a few; num2 sama dengan 2 + 6; num1 = num2 / several;

d. num1 + num2 = newNum;

e. back button = 12 * num1 - 12-15. 3;

farreneheit. num1 * 2 = newNum;

g. x / y = x 5. y;

l. num2 = num1 % 2 . zero;

i. newNum = static_cast (x) % 5;

t. x = x + 5;

t. newNum = num1 & static_cast (4. 6 as well as 2);

several. For each in the following lines of varying declarations, recognize it because valid or describe why is the line broken.

Line 1: n = 12;

Collection 2: char letter =;

Line 3: int one = five, two;

Collection 4: dual x, y, z;

5....