Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Evaluate the Boolean expression below if the variables have the following val

ID: 3539017 • Letter: 1

Question

1. Evaluate the Boolean expression below if the variables have the following values:


//variable definitions

int x = 5;

double num = 7.0;

bool mark = true;

int y = 10;

int z = -7;

bool more = false;


// bool expression:

bool expression = more or (z < x);




True or False?


2. Which of the following expression is equivalent to the logical expression (p >= q)


a. p < q

b. not p < q

c. !(p < q)

d. p>q


3. What is the output of the following code:


int a = 6, b = 4;

if (a + b < 10)

a = 5;

else

a = a + 1;

a = a + 2;

cout << a;


a. 7

b. 9

c. 5

d. 6


4. What is the value of p after the following code executes: (Explain how you get this to me thanks)


int p = 3, q = 5;

if (( p>q ) or ( p != 4))

p = p + 1;

else

p = p - 1;

p = p * 2;


a. 3

b. 8

c. 6

d. 4


Explanation / Answer

1

True


2

b


3

b


4

b ( p != 4) is valid so if executes and p=p+1=4 then p=p*2 executes and hence =4*2=8