Save
...
1stY - All about Computer Programming 1
1stQ - AI-Made Questions - Computer Programming 1
Lesson 7-8 (AI-Made)
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Marc
Visit profile
Cards (35)
What are the three main ways a computer can process a program?
Sequence
,
selection
(
branching
), and
repetition
(
looping
)
View source
What are control structures in programming?
They are building blocks that dictate the
flow
of a program’s execution
View source
How do control structures affect applications or programs?
They make applications
dynamic
and
responsive
to different scenarios
View source
What are the different types of selection structures in programming?
One-Way Selection
Two-Way Selection
Multiple
Selections
Compound (Block) Statements
Nested Selections
Switch Structure
Conditional Operator
View source
What is a one-way selection structure also known as?
Single alternative structure
View source
What happens in a one-way selection structure when the condition is false?
It skips the
control structure
block and proceeds to the
next statement
View source
What is the reserved word used in a one-way selection structure?
If
View source
What is the role of the expression in a one-way selection structure?
It is the logical expression that results in either
TRUE
or
FALSE
View source
What is a two-way selection structure also known as?
Double alternative structure
View source
What occurs in a two-way selection structure when the condition is true?
A certain block of statements is
executed
View source
What reserved words are used in a two-way selection structure?
If
and
else
View source
What must every else be paired with in a multiple selections structure?
An
if
View source
What is the purpose of a multiple selections structure?
To evaluate multiple
conditions
or possible
outcomes
View source
How do if…else statements differ from a series of if statements?
If…else statements skip the rest if the first condition is
true
View source
What is a compound statement in C++?
A structure that allows
multiple
or
complex
statements
View source
What encloses a compound statement?
Curly braces
View source
What is a nested if selection structure?
An
if statement
within another
if
statement
View source
What is the purpose of a switch structure?
To execute different parts of
code
based on a
single
value
View source
What types of values is a switch structure typically used for?
Integers
,
characters
, or
enumerated
types
View source
What is the role of the break statement in a switch structure?
It causes the switch structure to
exit
View source
What is the conditional operator also known as?
Ternary operator
View source
How many arguments does the conditional operator take?
Three
View source
What does the cin.fail() function do in C++?
It checks if the input value is
valid
View source
What is the purpose of the try and catch in exception handling?
To handle
errors
and
unexpected
events
gracefully
View source
What does the throw keyword do in exception handling?
It is used to throw an
exception
View source
What is short-circuit evaluation?
A process where the computer evaluates a logical expression from
left to right
View source
How does the logical AND (&&) work in short-circuit evaluation?
If the first expression is
FALSE
, the rest will not be evaluated
View source
How does the logical OR (||) work in short-circuit evaluation?
If the first expression is
TRUE
, the rest will not be evaluated
View source
What are the parameters of the cin.fail() function in input validation?
cin.fail
(): checks if the input failed
cin.clear
(): resets the failure state of cin object
cin.ignore
(
n
,
delim
): skips or discards characters in the input buffer
View source
What is the syntax for exception handling in C++?
try
{
//
code
that might throw an exception
}
catch (
exception_type
exception_object
) {
//
Code
to handle the exception
}
View source
What is the role of the break statement in a switch structure?
It exits the switch structure to prevent
fall-through
View source
What is the purpose of the default case in a switch structure?
It executes if no case matches the value of the
expression
View source
What is a conditional operator in C++?
It is a shorthand for an
if-else
statement using the
?
:
symbol
View source
What are the three components of a conditional operator?
expression1
,
expression2
, and
expression3
View source
What is short-circuit evaluation?
It evaluates a
logical expression
from left to right and stops as soon as the
final value
is known
View source