Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b

Question 1

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;

A)

5

B)

4

C)

3

D)

6

Question 2

Which statement results in the value false?

The value of count is 0; limit is 10.

A)

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

B)

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

C)

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

D)

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

Question 3

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

g(1,2);

A)

void g(double value, int count);

B)

None listed

C)

int g(int count, double value);

D)

void g(int value, int count);

Question 4

A call to a C++ function is

A)

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

B)

The name of the function followed by empty parentheses

C)

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

D)

The name of the function only

Question 5

Which is incorrect regarding

a void function

A)

performs some action and returns a value

B)

performs some action but does not return a value

C)

is a statement

D)

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

Question 6

Which is incorrect?

The sqrt function

A)

is provided in the library header

B)

the argument type is int

C)

returns the square root of the argument

D)

the return type is double

Question 7

Which statement results in the value false?

The value of count is 0; limit is 10.

A)

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

B)

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

C)

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

D)

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

Question 8

The following program purports to sum all entered int values that are greater than 5. It compiles without any error message, and it executes without error message, but nevertheless is wrong. Which statement is incorrect?

// Display the sum of all entered int values // greater than 5 #include

int main() { using namespace std; int x, sum; while (x < 10) { cin >> x; if (x > 5); sum = sum +x; } cout << The sum is values > 5 is << sum << endl; }

A) The semicolon at the end of the if statement is an error that the compiler should catch

B) The variable x is not initialized, so the loop may or may not execute

C) The semicolon at the end of the if statement causes all entered values to be summed

D) The sum variable is not initialized, so the output value is most likely garbage

Question 9

A switch statement must have

A)

None listed

B)

a default case

C)

a break statement

D)

more than one non-default case

Question 10

What is incorrect about the expression below?

left && right

A)

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

B)

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

C)

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

D)

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

Question 11

Which is correct?

A)

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.

B)

A break statement is used in loops only.

C)

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

D)

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

Question 12

Which of the following determines the operator that is processed prior to another operator?

A)

None listed

B)

Operator associativity

C)

Whether the operator is an arithmetic operator

D)

Operator precedence

Question 13

Which of the following control structures requires curly braces?

A)

while

B)

switch

C)

for

D)

if-else

Question 14

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

A)

Any non-zero value

B)

1

C)

0

D)

true

Question 15

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

A)

all listed

B)

while(control) {body};

C)

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

D)

do {body} while(control)

Question 16

In the expression (j > 0 && j+1 == 10), which operator executes last?

A)

>

B)

+

C)

&&

D)

==

Question 17

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;

A)

4

B)

3

C)

5

D)

6

Question 18

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

A)

while statement

B)

if-else statement

C)

switch

D)

do -while statement

Question 19

In a switch statement, when a break statement is encountered, an immediate transfer of control is made to

A) the default case of the switch statement

B) a goto statement

C) the else statement

D) the statement beyond the end of the switch statement

Question 20

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

A)

It can have two operands

B)

It is the logical OR operator

C)

It returns true if both operands are true

D)

It uses short circuit evaluation

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago