Control Structures in Programming

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

17 Terms

1
New cards

Selection control structure

A structure that chooses which set of statements to execute based on a condition.

2
New cards

Control structure effect on program flow

Alters the normal sequential flow by allowing decisions and repetitions.

3
New cards

Correct syntax of an if-else statement

if (condition) { / code / } else { / code / }

4
New cards

Relational operators (comparison)

==, !=, <, >, <=, >=

5
New cards

Logical (Boolean) operators

&& (AND), || (OR), ! (NOT)

6
New cards

Order of precedence (highest to lowest)

! > && > ||

7
New cards

Short Circuit Evaluation

The process where evaluation stops as soon as the result is known (e.g., in false && ..., the rest is skipped).

8
New cards

Conditional operator syntax (?:)

condition ? value_if_true : value_if_false;

9
New cards

Switch statement syntax

switch (expression) { case value1: / code /; break; case value2: / code /; break; default: / code /; }

10
New cards

Reserved words in switch

switch, case, break, default

11
New cards

Nested control structure

A control structure inside another, e.g., if inside a for loop.

12
New cards

Does if (x = 5) check equality?

No, it assigns 5 to x. Use == for equality.

13
New cards

Can switch evaluate strings in standard C++?

No, only integral types like int and char.

14
New cards

Logical NOT precedence

Higher than && and ||

15
New cards

Purpose of break in switch

Exits the switch block to prevent fall-through.

16
New cards

What does this print? cout << ((a < b) ? "Yes" : "No");

Yes (if a = 3, b = 4)

17
New cards

What does this print? int choice = 2; switch (choice) { case 1: cout << "One"; break; case 2: cout << "Two"; case 3: cout << "Three"; break; default: cout << "Other"; }

TwoThree (no break after case 2)