Question: 1. Consider the following code segment. int test1 = 7; int test2 = 2; int test3 = 5; int average = (test1 / test2) +

1. Consider the following code segment.

int test1 = 7;

int test2 = 2;

int test3 = 5;

int average = (test1 / test2) + test3;

printf(%d , average);

What is printed as a result of executing the code segment?

(A) 8

(B) 8.5

(C) 8.0

(D) 7.5

(E) 7

2. Consider the following function header.

double rectArea(int width, int height)

Assuming that the function rectArea is declared as showm above, which of the following statements are valid invocations of the rectArea function?

(A) int area = rectArea(5);

(B) double area = rectArea(5.0, 3.0);

(C) double area = rectArea(5, 3);

(D) int area = rectArea(5.0);

(E) Both A and B.

.

3. Consider the following code segment.

int today;

int tomorrow = 3;

int yesterday = today - 1;

printf(%d , yesterday);

What is printed as a result of executing the code segment?

(A) 1

(B) 2

(C) 0

(D) Nothing is printed because no value is assigned to the today variable.

(E) Nothing is printed because the yesterday variable is never declared.

4. Consider the following function.

int remainder(int a, int b)

{

return a % b;

}

Which of the following method invocations will return 0?

(A) remainder(22, 7)

(B) remainder(10, 3)

(C) remainder(5, 2)

(D) remainder(5, 5)

(E) remainder(101, 10)

5. Consider the following code segment.

int a = 45;

int b = 21;

int tmp = a;

a = b;

b = tmp;

printf(%d , a / 2);

What is printed as a result of executing the code segment?

(A) 10

(B) 10.5

(C) 21

(D) 22

(E) 22.5

Please post the right solution and also give the reason why you chose the answers. Explanation and Reasoning is needed. Please pass if you can supply the explanation and reasoning. Thanks,

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!