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

QUESTION 1 Which statement results in the value false? The value of count is 0;

ID: 3853773 • Letter: Q

Question

QUESTION 1

Which statement results in the value false?

The value of count is 0; limit is 10.

(count != 0)&&(limit < 20)

(count == 0)&&(limit < 20)

(count != 0)||(limit < 20)

(count == 0)&&(limit < 20)

10 points   

QUESTION 2

If this code fragment were executed in an otherwise correct and complete program, what would the output be?
int a = 3, b = 2, c = 5
if (a > b)
a = 4;
if ( b > c)
   a = 5;
   else
    a = 6;
cout << a << endl;

5

3

6

4

10 points   

QUESTION 3

Which is incorrect regarding

a void function

performs some action and returns a value

performs some action but does not return a value

is a statement

A void function may have a return statement but is not required to have one.

10 points   

QUESTION 4

Which statement results in the value false?

The value of count is 0; limit is 10.

(count == 0)&&(limit < 20)

(count == 0)&&(limit < 20)

(count != 0)||(limit < 20)

(count != 0)&&(limit < 20)

10 points   

QUESTION 5

Which of the following overloadings will be invoked by this call?

g(1,2);

void g(int value, int count);

void g(double value, int count);

int g(int count, double value);

None listed

10 points   

QUESTION 6

Which is incorrect?

The sqrt function

is provided in the <cmath> library header

the argument type is int

returns the square root of the argument

the return type is double

10 points   

QUESTION 7

A call to a C++ function is

The name of the function followed by exactly the number of arguments as there are parameters in the definition

The name of the function followed by empty parentheses

The name of the function followed by any number of arguments, regardless of the number of parameters in the definition

The name of the function only

10 points   

QUESTION 8

Which is correct?

In a do-while loop, a continue statement terminates the loop

In a while loop, the Boolean_Expression is executed before each execution of the loop body.

When a loop is nested in side another loop, a break or continue statement terminates or restarts the outermost loop of the nested loop structure.

A break statement is used in loops only.

10 points   

QUESTION 9

If this code fragment were executed in an otherwise correct and complete program, what would the output be? .

int a = 3, b = 2, c = 5

if (a > b)

a = 4;

if ( b > c)

a = 5;

else

a = 6;

cout << a < endl;

3

6

5

4

10 points   

QUESTION 10

Which of the following is NOT correct about the || operator?

It uses short circuit evaluation

It returns true if both operands are true

It is the logical OR operator

It can have two operands

10 points   

QUESTION 11

Which control construct repeats a sequence of statements zero or more times?

if-else statement

switch

do -while statement

while statement

10 points   

QUESTION 12

Consider the if statement:

if(condition) yes_clause; else no_clause;

Under which of the following circumstances will both the yes_clause and the no_clause will be executed?

When the condition is false

When the condition is true

This will not happen

When the condition is ambiguous

10 points   

QUESTION 13

Which is incorrect?

The value of count is 0; limit is 10. The following evaluates as true:

(count == 0)&&(limit < 20)

The value of count is 0; limit is 10. The following evaluates as true:

count == 0 && limit < 20

You want to determine whether time has run out. The following code correctly implements this.

            !time > limit

The  if, while and for statements control only one statement.

10 points   

QUESTION 14

Which of the following loop statements is guaranteed to iterate the body of the loop at least once?

while(control) {body};

do {body} while(control)

all listed

for(initialize;test:update){body};

10 points   

QUESTION 15

If the following code fragment is executed in an otherwise complete and correct program, which expression will be executed?

x = 0;

if (x = 12)

yes_statement;

else

no_statement;

The no_statement will be executed because x is not 12.

The statement has incorrect syntax so will not compile at all

The yes_statement will be executed.

x=12 is illegal in the Boolean expression of an if statement

10 points   

QUESTION 16

When you don’t recall operator precedences you can

Look in a table of precedences

Guess

Use parentheses

Experiment with the compiler

10 points   

QUESTION 17

In distinguishing an expression as true or false, C++ sees which of the following as true?

true

0

Any non-zero value

1

10 points   

QUESTION 18

What is incorrect about the expression below?

left && right

The expression is true when left is true and right is true

The expression is false when left is false and right is false

The expression is true when left is true and right is false

The expression is false when left is false and right is true

10 points   

QUESTION 19

What is incorrect about the following expression?

left || right

The expression is false when left is false and right is true

The expression is true when left is true and right is false

The expression is false when left is false and right is false

The expression is true when left is true and right is true

10 points   

QUESTION 20

Regarding the comma operator, which statement is incorrect?

Results in the value equal to the value of the first expression in the list

ANSI C++ Standard specifies that expressions must be evaluated left to right

Is used to separate a list of expressions

Expressions are evaluated in order defined by the compiler

(count != 0)&&(limit < 20)

(count == 0)&&(limit < 20)

(count != 0)||(limit < 20)

(count == 0)&&(limit < 20)

Explanation / Answer

Q1. Ans (count != 0)&&(limit < 20)

explaination: count is equal to zero as this is false resot of And operation is false

Q2. it displays 6

first if checks a > b which is true then a becomes 4 , nextx statementr check if b > c which is false so a is assigned value 6

Q3. Ans: performs some action and returns a value

Explaination: void function does not return any value

Q4. Ans:(count == 0)&&(limit < 20)

Q5: Ans: void g(int value, int count);

explaination:since g is called with both input parameters integer , above function is called

Q6: Ans: the argument type is int

Sqrt takes arguments of type double

Q7: Ans: The name of the function followed by exactly the number of arguments as there are parameters in the definition

Q8: Ans:In a while loop, the Boolean_Expression is executed before each execution of the loop body.

Q9: Ans: 6

Q10: Ans: It returns true if both operands are true

Q11: Ans :if-else statement

Q12: Ans :This will not happen

Q13: Ans:The  if, while and for statements control only one statement.

Q14: Ans: do {body} while(control)

Q15: Ans: The yes_statement will be executed.

Q16: Ans: Use parentheses

Q17: Ans:Any non-zero value

Q18: Ans: The expression is true when left is true and right is false

Q19: Ans:The expression is false when left is false and right is true

Q20: Ans: Results in the value equal to the value of the first expression in the list

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote