BTE 320 MIDTERM

Ace your homework & exams now with Quizwiz!

is an arithmetic operator that gives the remainder of a division problem

%

X is an int and Ch is a char. The input is: 276. Code is: cin>> ch >> x;

Ch= '2', x = 76 (Ch= first character)

Suppose that x and y are int variables. What is a valid input statement?

Cin >> x >> y;

a posttest loop begins with _____

Do

What loop is Useful in menu-driven programs to bring user back to menu to make another choice?

Do While loop

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) ____ while loop. Select one: a. sentinel-controlled b. flag-controlled c. EOF-controlled d. counter-controlled

EOF

(T/F) In C++, the names of the corresponding formal and actual parameters must be the same

False

(T/F) In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read.

False

(T/F) It is possible that the body of a while loop may not execute at all, but the body of a for loop executes at least once.

False

(T/F) Loop control variables are automatically initialized in a loop.

False

(True or False) A variable name cannot be passed to a value parameter

False

t./f? A counter doesn't have to to be initialized before entering the loop.

False

t/f in a for loop You can't have multiple statements in the test expression. Separate the statements with a comma

False

t/f the for loop is not a pretest loop?

False

(T/F) In a counter-controlled while loop, it is necessary to initialize thee loop control variable

False (It is) (always want to initialize)

(T/F) A value-returning function returns only integer values

False (Only returns one value. Can return a char, bool) (can't return an array)

(T/F) A do...while loop is called a pretest loop

False (Post test) (one that executes for sure once and then evaluates at the bottom and may or may not go again)

The value of the expression (24>=35) && ('A'<'B') is:

False. First has to be true

A(n) ____-controlled while loop uses a bool variable to control the loop. Select one: a. counter b. sentinel c. flag d. EOF

Flag

a data type that holds numbers with fractional components

Float

can hold a sequence of characters

String

(T/F) A loop is a control structure that allows you to repeat a set of statements until certain conditions are met.

True

(T/F) A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value.

True

(T/F) After a break statement executes, the program continues to execute with the first statement after the structure.

True

(T/F) Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5. n = 1; while (n < 5) { n++; cout << n << " "; }

True

(T/F) In a counter-controlled while loop, the loop control variable must be initialized before the loop.

True

(T/F) In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.

True

(T/F) The control variable in a flag-controlled while loop is a bool variable.

True

(T/F) The execution of a break statement in a while loop terminates the loop.

True

(T/F) The function eof returns true if the program has read past the end of the input file.

True

(True or False) A function that changes the value of a reference parameter also changes the value of the actual parameter

True

(True or False) If a C++ function does not use parameters, parentheses around the empty parameter are still required.

True

(True or False) Parameters allow you to use different values each time the function is called

True

A nested loop is a loop inside the body of another loopt/f?

True

t/f in a for loop You can declare variables in the initialization expression

True

t/f? a Do-while Loop always executes at least once

True

t/f? counters can be used to control execution of the loop

True

t/t in a for loop You can have multiple statements in the initialization expression?

True

(T/F) It is possible that the body of a while loop may not execute at all

True (The body for a for loop executes at least once but not a while loop) (you evaluate a while loop first) (also true for an if statement)(a do while loop executes once)

(T/F) A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value

True (The first item is read before the while loop is entered)

(T/F) When a return statement executes in a user-defined function, the function immediately exits

True (Wherever it says return, it leaves that function and goes to the next)

The value of the expression !('A'>'B') is:

True. A is not > than B

The value of the expression (14 >= 5) || ('A' > 'B') is:

True. OR.

in a nested loop does the Inner loop goes through all repetitions for each repetition of outer loop?

Yes

A do while loop Execution continues as long as... , and stops repetition when ...

as expression is true, expression becomes false

data types only have two values: true and false

bool

The ____ statement can be used to eliminate the use of certain bool variables in a loop. Select one: a. if b. while c. switch d. break

break

What header file must be included to use the pow function?

cmath

This loop should be used:In any situation that clearly requiresan initializationa false condition to stop the loopan update to occur at the end of each iteration

for loop

To use the functions peek and putback in a program, which header file(s) must be included?

iostream

What does sum += num mean?

sum = sum + num

Which of the following is not a . relational operator: >, ==, !=, ||

|| (OR)


Related study sets

Managerial economics Salvatore 8th Edition, chapter 1

View Set

2. Exercise for Exploring Linux Command-Line Tools, Linux Essentials 010-150 Part 2, Chapter 14, Linux Ch 7, 1.12 Regular Expressions, 211 Final, Quiz 2 (Linux), LINUX TEST 3, Chapter 10: Editing Files (Review Questions), Chapter 9, Liinux Study, Hom...

View Set

A&P Online Exam #2 prep questions

View Set

Ch 1-9 & ch 12 practice question

View Set

Chapters 15 & 16 - Bloodflow and Blood Pressure

View Set

AWS Cloud Practitioner Practice questions

View Set

Traducción profesional y académica Estudios Ingleses UNED- vocabulary Birth Certificate, Uni Degree, Student transcript and will

View Set