Quiz 4

Ace your homework & exams now with Quizwiz!

What will be the value of x after the following code is executed? x ← 5 WHILE (x >= 0) x ← x -1 ENDWHILE

-1

What will be the value of x after the following code is executed? x ← 1 WHILE (x < 0) x ← x + 1 ENDWHILE

1

How many times will the following for loop be executed? FOR (count ←1, count <= 10, count ← count +1) PRINT "CSE 1321 is great!!!" END FOR

10

What will be the value of x after the following code is executed? x ← 0, y ← 2 WHILE(x < 10) x ← x + y y ← y + 1 ENDWHILE

14

What will be the value of x after the following code is executed? x ← 10 FOR(y ← 5, y < 20, y ← y + 5) x ← x + y ENDFOR

40

What will be the value of x after the following code is executed? x ← 0 WHILE ( x < 5 ) x ← x + 1 ENDWHILE

5

What will be printed after the following code is executed? FOR(number ← 5, number <= 15, number ← number + 3) PRINT number, ", " ENDFOR

5, 8, 11, 14

Each repetition of a loop is known as what?

An iteration

If a loop does not contain within itself a way to terminate, it is called a(n):

Infinite Loop

This is a control structure that causes a statement or group of statements to repeat.

Loop

This variable controls the number of times that the loop iterates.

Loop control variable

In the following code, what values could be read into number to terminate the while loop? PRINT "Enter a number: READ user input number ← user input WHILE (number < 1 or number > 10) PRINT "Enter another number: " READ user input number ← user input END WHILE

Numbers in the range on 1 - 10

In the following code, what values could be read into number to terminate the while loop? PRINT "Type in a number" READ input number ← user input WHILE ( number > 0 ) PRINT "No, that is not it. Try again." READ input number ← user input ENDWHILE

Numbers less than or equal to 0

In counter-controlled repetition, we can set the incrementation to any value.

True

This keyword will cause the loop to terminate immediately.

break

This type of loop should be used when you want your loop to iterate at least once.

do while

This type of loop is ideal in situations where the exact number of iterations is known.

for loop

Use this loop any time that you do not know the exact number of iterations that need to execute.

while


Related study sets

2) Clinical Safety: The Core of Leading, Managing, & Following

View Set

QUIZ-19 (GRADED)-RESPIRATORY SYSTEM

View Set

NUR 212 EXAM 4 - PRACTICE QUESTIONS, KEY TERMS

View Set

ChatGPT - a blessing or curse? Eng - PL

View Set

Chapter 11 retailing and wholesaling

View Set

A & P Chapter 21 Peripheral Nervous System

View Set

development part 1 practice questions

View Set

FL statutes rules and regulations pertinent to Health insurance

View Set

Gerontology Exam practice questions

View Set