C++ Control Structures and Conditions Quiz

SpellboundOwl avatar
SpellboundOwl
·
·
Download

Start Quiz

Study Flashcards

28 Questions

What type of statement is the if selection statement?

Single-selection statement

How does a switch selection statement differ from an if...else statement?

Switch selection statement is a multiple-selection statement, while if...else is a double-selection statement.

What must a flowchart describing a selection structure begin with?

Decision symbol

What does a pseudocode for a selection structure start with and end with?

'if' and 'endif'

How many courses of action can an if...else statement select between?

Two different actions

What are the five logical conditions supported by C++?

Less than, Less than or equal to, Greater than, Greater than or equal to, Equal to, Not Equal to

What did mathematicians prove in the mid-1960s about constructing programs?

Any program, no matter how complicated, can be constructed using one or more of only three structures.

What is a sequence structure in programming?

A sequence structure is where you perform an action or task, and then you perform the next action, in order.

What is the limitation of a sequence structure?

There is no option to branch off and skip any of the tasks.

What is the second of the three basic structures in programming?

Selection structure or decision structure

What does a selection structure allow in programming?

A selection structure allows branching based on a condition, creating decision paths.

What is a loop structure?

A loop structure allows you to repeat actions while a condition remains true.

What are the actions within a loop known as?

The actions within a loop are known as the loop body.

What is another name for a while loop according to the text?

while...do

How does a loop typically work?

A condition is evaluated, if true, the loop body is executed, and the condition is re-evaluated.

How does pseudocode for a loop start and end?

Pseudocode for a loop starts with 'while' and ends with 'endwhile'.

What does a flowchart describing a loop structure always begin with?

A decision symbol that has a branch returning to a spot prior to the decision.

What does stacking structures mean in the context of programming?

Attaching structures end to end

What are the three basic structures that can be used to solve all logic problems?

sequence, selection, and loop

What are the two end-structure statements shown in the pseudocode in Figure 3-6?

endif and endwhile

Give an example of a daily situation where looping occurs according to the text.

while unread pages remain in the reading assignment read another unread page

What type of structure is used when multiple tasks are followed in a specific order?

sequence

What is the purpose of the else statement in an if...else structure?

To execute when the tested condition is false.

What happens to the instructions after the endif statement?

They are not dependent on the if statement at all.

What does an endwhile statement indicate in a loop structure?

It shows where the loop structure ends.

What is nesting structures in pseudocode?

Placing a structure within another structure.

What does the indentation in pseudocode signify?

That the indented statements must execute together if a certain condition is true.

What do you call a group of statements that execute as a single unit in pseudocode?

A block.

Study Notes

Control Structures

  • A control structure is a basic unit of programming logic, and each structure is one of the following: sequence, selection, or loop.

Sequence Structure

  • A sequence structure performs a series of actions in order, with no option to branch off and skip any tasks.
  • A flowchart that describes a sequence structure never contains a decision symbol, and pseudocode that describes a sequence structure never contains an if or a while.
  • A sequence can contain any number of tasks, but once started, the sequence must be completed step by step until the end.

Selection Structure

  • A selection structure, also known as a decision structure, chooses between two different actions (or groups of actions) based on a condition.
  • A flowchart that describes a selection structure must begin with a decision symbol, and the branches of the decision must join at the bottom of the structure.
  • Pseudocode that describes a selection structure must start with if and end with endif.

Loop Structure

  • A loop structure repeats actions while a condition remains true.
  • The action or actions that occur within the loop are known as the loop body.
  • A flowchart that describes a loop structure always begins with a decision symbol that has a branch that returns to a spot prior to the decision.
  • Pseudocode that describes a loop starts with while and ends with endwhile.

Stacking and Nesting Structures

  • Structures can be combined in an infinite number of ways by stacking or nesting them.
  • Stacking structures involves attaching structures end to end, while nesting structures involves placing a structure within another structure.

Important Concepts

  • Any program, no matter how complicated, can be constructed using only the three basic structures: sequence, selection, and loop.
  • Loops can be thought of as repetition or iteration, and can be used to repeat actions while a condition remains true.

Test your knowledge on control structures, conditions, and if statements in C++. Learn about logical conditions such as less than, greater than, equal to, and more. Understand the three basic structures used in programming logic.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser