Cards (35)

  • What are the three main ways a computer can process a program?
    Sequence, selection (branching), and repetition (looping)
  • What are control structures in programming?
    They are building blocks that dictate the flow of a program’s execution
  • How do control structures affect applications or programs?
    They make applications dynamic and responsive to different scenarios
  • 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
  • What is a one-way selection structure also known as?
    Single alternative structure
  • 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
  • What is the reserved word used in a one-way selection structure?
    If
  • 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
  • What is a two-way selection structure also known as?
    Double alternative structure
  • What occurs in a two-way selection structure when the condition is true?
    A certain block of statements is executed
  • What reserved words are used in a two-way selection structure?
    If and else
  • What must every else be paired with in a multiple selections structure?
    An if
  • What is the purpose of a multiple selections structure?
    To evaluate multiple conditions or possible outcomes
  • How do if…else statements differ from a series of if statements?
    If…else statements skip the rest if the first condition is true
  • What is a compound statement in C++?
    A structure that allows multiple or complex statements
  • What encloses a compound statement?
    Curly braces
  • What is a nested if selection structure?
    An if statement within another if statement
  • What is the purpose of a switch structure?
    To execute different parts of code based on a single value
  • What types of values is a switch structure typically used for?
    Integers, characters, or enumerated types
  • What is the role of the break statement in a switch structure?
    It causes the switch structure to exit
  • What is the conditional operator also known as?
    Ternary operator
  • How many arguments does the conditional operator take?
    Three
  • What does the cin.fail() function do in C++?
    It checks if the input value is valid
  • What is the purpose of the try and catch in exception handling?
    To handle errors and unexpected events gracefully
  • What does the throw keyword do in exception handling?
    It is used to throw an exception
  • What is short-circuit evaluation?
    A process where the computer evaluates a logical expression from left to right
  • How does the logical AND (&&) work in short-circuit evaluation?
    If the first expression is FALSE, the rest will not be evaluated
  • How does the logical OR (||) work in short-circuit evaluation?
    If the first expression is TRUE, the rest will not be evaluated
  • 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
  • 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
    }
  • What is the role of the break statement in a switch structure?
    It exits the switch structure to prevent fall-through
  • What is the purpose of the default case in a switch structure?
    It executes if no case matches the value of the expression
  • What is a conditional operator in C++?
    It is a shorthand for an if-else statement using the ?: symbol
  • What are the three components of a conditional operator?
    expression1, expression2, and expression3
  • What is short-circuit evaluation?
    It evaluates a logical expression from left to right and stops as soon as the final value is known