Exam 5: Control Structures II (Repetition)

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

To generate a random number,you can use the function rand of the header file ____________________.

Free
(Short Answer)
4.8/5
(97)
Correct Answer:
Verified

cstdlib

Which of the following statements generates a random number between 0 and 50?

Free
(Multiple Choice)
5.0/5
(85)
Correct Answer:
Verified

A

Assume that all variables are properly declared.The following for loop executes 20 times. for (i = 0; i <= 20; i++) \quad cout << i;

Free
(True/False)
4.8/5
(92)
Correct Answer:
Verified

False

____ loops are called posttest loops.

(Multiple Choice)
4.7/5
(63)

What is the output of the following C++ code? num = 10; while (num > 10) \quad num = num - 2; cout << num << endl;

(Multiple Choice)
4.7/5
(83)

Consider the following code. int limit; Int reps = 0; Cin >> limit; While (reps < limit) { \quad Cin >> entry; \quad Triple = entry * 3; \quad Cout << triple; \quad Reps++; } Cout << endl; This code is an example of a(n)____ while loop.

(Multiple Choice)
4.9/5
(80)

The control statements in the for loop include the initial statement,loop condition,and update statement.

(True/False)
4.9/5
(74)

What is the initial statement in the following for loop? (Assume that all variables are properly declared.) int i; For (i = 1; i < 20; i++) \quad Cout << "Hello World"; \quad Cout << "!" << endl;

(Multiple Choice)
4.8/5
(78)

Putting one control structure statement inside another is called ____________________.

(Short Answer)
4.8/5
(80)

In ____ structures,the computer repeats particular statements a certain number of times depending on some condition(s).

(Multiple Choice)
4.8/5
(88)

In a while and for loop,the loop condition is evaluated before executing the body of the loop.Therefore,while and for loops are called ____________________ loops.

(Short Answer)
4.8/5
(82)

A loop that continues to execute endlessly is called a(n)____ loop.

(Multiple Choice)
4.8/5
(67)

What executes immediately after a continue statement in a while and do-while loop?

(Multiple Choice)
4.9/5
(69)

A semicolon at the end of the for statement (just before the body of the loop)is a(n)____________________ error.

(Short Answer)
4.8/5
(79)

A do...while loop is a(n)____________________ loop,since the loop condition is evaluated after executing the body of the loop.

(Short Answer)
4.7/5
(78)

The for loop body executes indefinitely if the loop condition is always ____________________.

(True/False)
4.9/5
(74)

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) { \quad Sum = sum + num; \quad Cin >> num; } Cout << sum << endl;

(Multiple Choice)
4.7/5
(64)

Which of the following is a repetition structure in C++?

(Multiple Choice)
4.8/5
(85)

What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { \quad num = num - 1; \quad count++; } cout << count << " " << num << endl;

(Multiple Choice)
4.7/5
(75)

Which executes first in a do...while loop?

(Multiple Choice)
4.9/5
(90)
Showing 1 - 20 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)