Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count ==

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 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 dont 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions