COSC 1436 Practice

In a __ control structure, the computer executes particular statements depending on some condition(s).
a. looping
b. repetition
c. selection
d. sequence

c. selection

What does <= mean?
a. less than
b. greater than
c. less than or equal to
d. greater than or equal to

c. less than or equal to

Which of the following is a relational operator?
a =
b. ==
c. !
d. &&

b. ==

Which of the following is the "not equal to" relational operator?
a. !
b. I
c. !=
d. &

c. !=

Suppose x is 5 and y is 7. Choose the value of the following expression: (x ! = 7) & & (x <= y)
a. false
b. true
c. 0
d. null

b. true

Suppose that x is an int variable. Which of the following expressions always evaluates to true?
a. (x > 0) I I (x <= 0)
b. (x >= 0) I I (x == 0)
c. (x > 0) && ( x <= 0)
d. (x > 0) & & (x == 0)

a. (x > 0) I I (x <= 0)

Which of the following operators has the highest precedence?
a. !
b. *
c. %
d. =

a. !

Which of the following operators has the lowest precedence?
a. !
b. II
c. &amp;&amp;
d. =

d. =

Which of the following expressions correctly determines that x is greater than 10 and less than 20?
a. 10 &lt; x &lt; 20
b. ( 1 0 &lt; x &lt; 20)
c. 10 &lt; x &amp; &amp; x &lt; 20
d. 10 &lt; x I I x &lt; 20

c. 10 < x & & x < 20

The expression in an if statement is sometimes called a(n) __ .
a. selection statement
b. action statement
c. decision maker
d. action maker

c. decision maker

What is the output of the following C++ code?
int x = 35; int y = 45; int z;
if (x &gt; y) z = x + y;
else z = y - x;
cout « x « " " « y « " " « z « endl;
a. 35 45 80
b. 35 45 10
c. 35 45 -10
d. 35 45 0

b. 35 45 10

When one control statement is located within another, it is said to be __ .
a. blocked
b. compound
c. nested
d. closed

c. nested

What is the output of the following code?
if (6 &gt; 8) {
cout « " ** " « endl ;
cout « "****" « endl;
} else if (9 == 4)
cout « "***" « endl;
else cout « "*" « endl;
a. *
b. **
c. ***
d ****

a. *

To develop a program, you can use an informal mixture of C++ and ordinary language, called __ .
a. assert code
b. pseudocode
c. cppcode
d. source code

b. pseudocode

Which of the following will cause a logical error if you are trying to compare x to 5?
a. if (x == 5)
b. if (x = 5)
c. if (x &lt;= 5)
d. if (x &gt;= 5)

b. if (x = 5)

The appearance of = in place of == resembles a(n) __ .
a. syntax error
b. silent killer
c. compilation error
d. input failure

b. silent killer

The conditional operator ? : takes __ arguments.
a. two
b. three
c. four
d. five

b. three

What is the value of x after the following statements execute?
int x;
x = (5 &lt;= 3 &amp; &amp; 'A' &lt; 'F') ? 3 : 4
a. 2
b. 3
c. 4
d. 5

c. 4

Assume you have three int variables: x = 2, Y = 6 , and z. Choose the value of z in the following expression:
z = ( y / x &gt; 0) ? x : y;
a. 2
b. 3
c. 4
d. 6

a. 2

What is the output of the following code?
char lastlnitial = 'S';
switch (lastlnitial) {
case 'A': cout « "section 1" «endl; break;
case 'E': cout « "section 2" «endl; break;
case 'C': cout « "section 3" «endl; break;
case 'D': cout « "section 4" «endl; break;
default: cout « "section 5" «endl; }
a. section 2
b. section 3
c. section 4
d. section 5

d. section 5

What is the output of the following code?
char lastlnitial = 'A';
switch (lastlnitial) {
case 'A': cout « "section 1" «endl; break;
case 'E': cout « "section 2" «endl; break;
case 'C': cout « "section 3" «endl; break;
case 'D': cout « "section 4" «endl; break;
default: cout « "section 5" «endl; }
a. section 1
b. section 2
c. section 3
d. section 5

a. section 1

What is the output of the following code fragment if the input value is 4?
int num; int alpha = 10;
cin » num;
switch (num) {
case 3: alpha++; break;
case 4:
case 6: alpha = alpha + 3;case 8: alpha = alpha + 4; break;
default: alpha = alpha + 5; }
cout « alpha « endl;
a. 13
b. 14
c. 17
d. 22

a. 13

What is the output of the following C++ code?
int x = 55; int y = 5;
switch (x % 7) {
case 0:
case 1: y++;
case 2:
case 3: y = y + 2;
case 4: break;
case 5:
case 6: y = y - 3; }
cout « y « endl;
a. 2
b. 5
c. 8
d. 10

a. 2

For a program to use the assert function, it must include which of the following?
a. #include &lt;assert&gt; c. #include &lt;assertc&gt;
b. #include &lt;cassert&gt; d. #include NDEBUG

b. #include <cassert>

You can disable assert statements by using which of the following?
a. #include
b. #define
c. #clear NDEBUG
d. #define NDEBUG

d. #define NDEBUG

In __ structures, the computer repeats particular statements a certain number of times depending on some condition(s).
a. looping
b. branching
c. selection
d. sequence

a. looping

What is the output of the following C++ code?
count = 1; num = 25;
while (count &lt; 25) {
num = num - 1;
count++; }
cout « count « " " « num « endl;
a. 24 0
b. 24 1
c. 25 0
d. 25 1

d. 25 1

What is the output of the following C++ code?
num = 10;
while (num &gt; 10) num = num - 2; cout « num « endl;
a. 0
b. 6
c. 8
d. 10

d. 10

A loop that continues to execute endlessly is called a(n) __ loop.
a. end
b. unlimited
c. infinite
d. definite

c. infinite

Assume all variables are properly declared. What is the output of the following C++ code?
num = 100;
while (num &lt;= 150) num = num + 5;
cout « num « endl;
a. 150
b. 155
c. 160
d. 165

b. 155

Consider the following code.
int limit; int counter = 0;
cin » limit;
while (counter &lt; limit) {
cin » entry; triple = entry * 3;
cout « triple; counter++; }
cout « endl;
This code is an example of a(n) __ while loop.
a. flag-controlled
b. counter-controlled
c. BOF-controlled 
d. sentinel-controlled

b. counter-controlled

Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code?
sum = 0;
cin » num; while (num != -1) { sum = sum + num;
cin » num;
cout « sum « endl;
a. 92
b. 109
c. 110
d 119

c. 110

A(n) __ -controlled while loop uses a bool variable to control the loop.
a. counter
b. sentinel
c. flag
d. BOF

c. flag

Consider the following code. (Assume that all variables are properly declared.)
cin » ch;
while (cin) { cout « ch; cin » ch; } This code is an example of a(n) __ loop.
a. sentinel-controlled
b. flag-controlled
c.EOF-controlled
d. counter-controlled

c.EOF-controlled

What is the next Fibonacci number in the following sequence? 1, 1,2,3,5,8, 13,21, ...
a. 34
b. 43
c. 56
d. 273

a. 34

Which of the following is the initial statement in the following for loop? (Assume that all variables are properly declared.)
int i;
for (i = 1; i &lt; 20; i++)
cout « "Hello World";
cout « "!" « endl;
a. i = 1;
b. i &lt; 20;
c. i ++ ;
d cout « "Hello World";

a. i = 1;

What is the output of the following C++ code?
int j;
for (j = 10; j &lt;= 10; j++)
cout « j « " ";
cout « j « endl;
a. 10
b. 10 10
c. 10 11
d. 11 11

c. 10 11

Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code?
cin » sum;
cin » num;
for (j = 1; j &lt;= 3; j++) { cin » num; sum = sum + num; }
cout « sum « endl;
a. 24
b. 25
c. 41
d. 42

a. 24

Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code?
sum = 0;
cin » num;
for (int j = 1; j &lt;= 4; j++) { sum = sum + num; cin » num; }
cout « sum « endl;
a. 124
b. 125
c. 126
d 127

b. 125

Which executes first in a do ... while loop?
a. statement
b. loop condition
c. initial statement
d. update statement

a. statement

What is the value of x after the following statements execute?
int x = 5; int y = 30;
do x = x * 2;
while (x &lt; y);
a. 5
b. 10
c. 20
d. 40

d. 40

What is the output of the following loop?
count = 5;
cout « 'St';
do { cout « '0'; count--; }
while (count &lt;= 5);
a. St
b. Sto
c. Stop
d. This is an infmite loop.

d. This is an infmite loop.

__ loops are called post-test loops.
a. break
b. for
c. while
d. do ... while

d. do ... while

Which of the following loops is guaranteed to execute at least once?
a. counter-controlled while loop
b. for loop
c. do ... while loop
d. sentinel-controlled while loop

c. do ... while loop

Which of the following loops does not have an entry condition?
a. BOF-controlled while loop
b. sentinel-controlled while loop
c. do ... while loop
d. for loop

c. do ... while loop

Which of the following is a repetition structure in C++?
a. if
b. switch
c. while ... do
d. do ... while

d. do ... while

Which of the following is true about a do ... while loop?
a. The body of the loop is executed at least once.
b. The logical expression controlling the loop is evaluated before the loop is entered.
c. The body of the loop may not execute at all.
d. It cannot contain a break statement.

a. The body of the loop is executed at least once.

Which of the following is not a function of the break statement?
a. To exit early from a loop
b. To skip the remainder of a switch structure
c. To eliminate the use of certain bool variables in a loop
d. To ignore certain values for variables and continue with the next iteration of a loop

d. To ignore certain values for variables and continue with the next iteration of a loop

Which executes immediately after a continue statement in a while and do-while loop?
a. loop-continue test
b. update statement
c. loop condition
d. the body of the loop

a. loop-continue test

When a continue statement is executed in a __ ' the update statement always executes.
a. while loop
b. for loop
c. switch structure
d. do ... while loop

b. for loop

COSC 1436 Practice - Subjecto.com

COSC 1436 Practice

Your page rank:

Total word count: 1754
Pages: 6

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

In a __ control structure, the computer executes particular statements depending on some condition(s).
a. looping
b. repetition
c. selection
d. sequence

c. selection

What does &lt;= mean?
a. less than
b. greater than
c. less than or equal to
d. greater than or equal to

c. less than or equal to

Which of the following is a relational operator?
a =
b. ==
c. !
d. &amp;&amp;

b. ==

Which of the following is the "not equal to" relational operator?
a. !
b. I
c. !=
d. &amp;

c. !=

Suppose x is 5 and y is 7. Choose the value of the following expression: (x ! = 7) &amp; &amp; (x &lt;= y)
a. false
b. true
c. 0
d. null

b. true

Suppose that x is an int variable. Which of the following expressions always evaluates to true?
a. (x &gt; 0) I I (x &lt;= 0)
b. (x &gt;= 0) I I (x == 0)
c. (x &gt; 0) &amp;&amp; ( x &lt;= 0)
d. (x &gt; 0) &amp; &amp; (x == 0)

a. (x > 0) I I (x <= 0)

Which of the following operators has the highest precedence?
a. !
b. *
c. %
d. =

a. !

Which of the following operators has the lowest precedence?
a. !
b. II
c. &amp;&amp;
d. =

d. =

Which of the following expressions correctly determines that x is greater than 10 and less than 20?
a. 10 &lt; x &lt; 20
b. ( 1 0 &lt; x &lt; 20)
c. 10 &lt; x &amp; &amp; x &lt; 20
d. 10 &lt; x I I x &lt; 20

c. 10 < x & & x < 20

The expression in an if statement is sometimes called a(n) __ .
a. selection statement
b. action statement
c. decision maker
d. action maker

c. decision maker

What is the output of the following C++ code?
int x = 35; int y = 45; int z;
if (x &gt; y) z = x + y;
else z = y – x;
cout « x « " " « y « " " « z « endl;
a. 35 45 80
b. 35 45 10
c. 35 45 -10
d. 35 45 0

b. 35 45 10

When one control statement is located within another, it is said to be __ .
a. blocked
b. compound
c. nested
d. closed

c. nested

What is the output of the following code?
if (6 &gt; 8) {
cout « " ** " « endl ;
cout « "****" « endl;
} else if (9 == 4)
cout « "***" « endl;
else cout « "*" « endl;
a. *
b. **
c. ***
d ****

a. *

To develop a program, you can use an informal mixture of C++ and ordinary language, called __ .
a. assert code
b. pseudocode
c. cppcode
d. source code

b. pseudocode

Which of the following will cause a logical error if you are trying to compare x to 5?
a. if (x == 5)
b. if (x = 5)
c. if (x &lt;= 5)
d. if (x &gt;= 5)

b. if (x = 5)

The appearance of = in place of == resembles a(n) __ .
a. syntax error
b. silent killer
c. compilation error
d. input failure

b. silent killer

The conditional operator ? : takes __ arguments.
a. two
b. three
c. four
d. five

b. three

What is the value of x after the following statements execute?
int x;
x = (5 &lt;= 3 &amp; &amp; ‘A’ &lt; ‘F’) ? 3 : 4
a. 2
b. 3
c. 4
d. 5

c. 4

Assume you have three int variables: x = 2, Y = 6 , and z. Choose the value of z in the following expression:
z = ( y / x &gt; 0) ? x : y;
a. 2
b. 3
c. 4
d. 6

a. 2

What is the output of the following code?
char lastlnitial = ‘S’;
switch (lastlnitial) {
case ‘A’: cout « "section 1" «endl; break;
case ‘E’: cout « "section 2" «endl; break;
case ‘C’: cout « "section 3" «endl; break;
case ‘D’: cout « "section 4" «endl; break;
default: cout « "section 5" «endl; }
a. section 2
b. section 3
c. section 4
d. section 5

d. section 5

What is the output of the following code?
char lastlnitial = ‘A’;
switch (lastlnitial) {
case ‘A’: cout « "section 1" «endl; break;
case ‘E’: cout « "section 2" «endl; break;
case ‘C’: cout « "section 3" «endl; break;
case ‘D’: cout « "section 4" «endl; break;
default: cout « "section 5" «endl; }
a. section 1
b. section 2
c. section 3
d. section 5

a. section 1

What is the output of the following code fragment if the input value is 4?
int num; int alpha = 10;
cin » num;
switch (num) {
case 3: alpha++; break;
case 4:
case 6: alpha = alpha + 3;case 8: alpha = alpha + 4; break;
default: alpha = alpha + 5; }
cout « alpha « endl;
a. 13
b. 14
c. 17
d. 22

a. 13

What is the output of the following C++ code?
int x = 55; int y = 5;
switch (x % 7) {
case 0:
case 1: y++;
case 2:
case 3: y = y + 2;
case 4: break;
case 5:
case 6: y = y – 3; }
cout « y « endl;
a. 2
b. 5
c. 8
d. 10

a. 2

For a program to use the assert function, it must include which of the following?
a. #include &lt;assert&gt; c. #include &lt;assertc&gt;
b. #include &lt;cassert&gt; d. #include NDEBUG

b. #include <cassert>

You can disable assert statements by using which of the following?
a. #include
b. #define
c. #clear NDEBUG
d. #define NDEBUG

d. #define NDEBUG

In __ structures, the computer repeats particular statements a certain number of times depending on some condition(s).
a. looping
b. branching
c. selection
d. sequence

a. looping

What is the output of the following C++ code?
count = 1; num = 25;
while (count &lt; 25) {
num = num – 1;
count++; }
cout « count « " " « num « endl;
a. 24 0
b. 24 1
c. 25 0
d. 25 1

d. 25 1

What is the output of the following C++ code?
num = 10;
while (num &gt; 10) num = num – 2; cout « num « endl;
a. 0
b. 6
c. 8
d. 10

d. 10

A loop that continues to execute endlessly is called a(n) __ loop.
a. end
b. unlimited
c. infinite
d. definite

c. infinite

Assume all variables are properly declared. What is the output of the following C++ code?
num = 100;
while (num &lt;= 150) num = num + 5;
cout « num « endl;
a. 150
b. 155
c. 160
d. 165

b. 155

Consider the following code.
int limit; int counter = 0;
cin » limit;
while (counter &lt; limit) {
cin » entry; triple = entry * 3;
cout « triple; counter++; }
cout « endl;
This code is an example of a(n) __ while loop.
a. flag-controlled
b. counter-controlled
c. BOF-controlled 
d. sentinel-controlled

b. counter-controlled

Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code?
sum = 0;
cin » num; while (num != -1) { sum = sum + num;
cin » num;
cout « sum « endl;
a. 92
b. 109
c. 110
d 119

c. 110

A(n) __ -controlled while loop uses a bool variable to control the loop.
a. counter
b. sentinel
c. flag
d. BOF

c. flag

Consider the following code. (Assume that all variables are properly declared.)
cin » ch;
while (cin) { cout « ch; cin » ch; } This code is an example of a(n) __ loop.
a. sentinel-controlled
b. flag-controlled
c.EOF-controlled
d. counter-controlled

c.EOF-controlled

What is the next Fibonacci number in the following sequence? 1, 1,2,3,5,8, 13,21, …
a. 34
b. 43
c. 56
d. 273

a. 34

Which of the following is the initial statement in the following for loop? (Assume that all variables are properly declared.)
int i;
for (i = 1; i &lt; 20; i++)
cout « "Hello World";
cout « "!" « endl;
a. i = 1;
b. i &lt; 20;
c. i ++ ;
d cout « "Hello World";

a. i = 1;

What is the output of the following C++ code?
int j;
for (j = 10; j &lt;= 10; j++)
cout « j « " ";
cout « j « endl;
a. 10
b. 10 10
c. 10 11
d. 11 11

c. 10 11

Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code?
cin » sum;
cin » num;
for (j = 1; j &lt;= 3; j++) { cin » num; sum = sum + num; }
cout « sum « endl;
a. 24
b. 25
c. 41
d. 42

a. 24

Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code?
sum = 0;
cin » num;
for (int j = 1; j &lt;= 4; j++) { sum = sum + num; cin » num; }
cout « sum « endl;
a. 124
b. 125
c. 126
d 127

b. 125

Which executes first in a do … while loop?
a. statement
b. loop condition
c. initial statement
d. update statement

a. statement

What is the value of x after the following statements execute?
int x = 5; int y = 30;
do x = x * 2;
while (x &lt; y);
a. 5
b. 10
c. 20
d. 40

d. 40

What is the output of the following loop?
count = 5;
cout « ‘St’;
do { cout « ‘0’; count–; }
while (count &lt;= 5);
a. St
b. Sto
c. Stop
d. This is an infmite loop.

d. This is an infmite loop.

__ loops are called post-test loops.
a. break
b. for
c. while
d. do … while

d. do … while

Which of the following loops is guaranteed to execute at least once?
a. counter-controlled while loop
b. for loop
c. do … while loop
d. sentinel-controlled while loop

c. do … while loop

Which of the following loops does not have an entry condition?
a. BOF-controlled while loop
b. sentinel-controlled while loop
c. do … while loop
d. for loop

c. do … while loop

Which of the following is a repetition structure in C++?
a. if
b. switch
c. while … do
d. do … while

d. do … while

Which of the following is true about a do … while loop?
a. The body of the loop is executed at least once.
b. The logical expression controlling the loop is evaluated before the loop is entered.
c. The body of the loop may not execute at all.
d. It cannot contain a break statement.

a. The body of the loop is executed at least once.

Which of the following is not a function of the break statement?
a. To exit early from a loop
b. To skip the remainder of a switch structure
c. To eliminate the use of certain bool variables in a loop
d. To ignore certain values for variables and continue with the next iteration of a loop

d. To ignore certain values for variables and continue with the next iteration of a loop

Which executes immediately after a continue statement in a while and do-while loop?
a. loop-continue test
b. update statement
c. loop condition
d. the body of the loop

a. loop-continue test

When a continue statement is executed in a __ ‘ the update statement always executes.
a. while loop
b. for loop
c. switch structure
d. do … while loop

b. for loop

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending