Understanding the use of the three basic programming constructs

Cards (34)

  • What is the most basic programming construct in which instructions are executed one after the other in a specific order?
    Sequential structures
  • Match the programming construct with its definition:
    Sequential ↔️ Instructions executed in order
    Conditional ↔️ Instructions executed based on a condition
    Iterative ↔️ Instructions repeated until a condition is met
  • Sequential structures allow programs to make decisions based on conditions.
    False
  • The if-else statement is a common example of a selection structure.

    True
  • Arrange the following steps in the correct order to determine if a number is positive or negative using a selection structure:
    1️⃣ Set the number
    2️⃣ Check if the number is greater than or equal to 0
    3️⃣ Print "The number is positive" if true
    4️⃣ Print "The number is negative" if false
  • A for loop allows a block of code to be executed a specific number of times
  • What is the defining characteristic of sequential structures?
    Executed in order
  • In a program to calculate the area of a rectangle, the area is computed using the formula: length * width
  • Comparison operators are used in selection structures to evaluate conditions.

    True
  • What is the primary purpose of iteration structures in programming?
    Repetition
  • What is the output of the given for loop?
    0, 1, 2, 3, 4
  • Iteration structures enable repetition of instructions until a condition is met.

    True
  • Sequential structures execute instructions based on a condition being true or false.
    False
  • Arrange the following steps in the correct order to calculate the area of a rectangle using a sequential structure:
    1️⃣ Set the length
    2️⃣ Set the width
    3️⃣ Multiply length by width
    4️⃣ Print the result
  • Selection structures use comparison operators such as less than (<), greater than (>), equal to (==), and not equal to (!=)
  • In a selection structure, the condition determines which instructions are executed.
  • What is a common example of an iteration structure that executes a block of code a specific number of times?
    For loop
  • Sequential structures are fundamental to programming because they allow tasks to be performed in a controlled and predictable manner
  • How do sequential structures compare to conditional structures?
    Executed in order
  • What are selection structures used for in programming?
    Decision-making
  • How do selection structures compare to sequential structures?
    Based on conditions
  • How many times does the 'print(i)' statement execute in the example for loop?
    5
  • Match the programming construct with its definition:
    Sequential ↔️ Instructions executed in order
    Selection ↔️ Instructions executed based on conditions
    Iteration ↔️ Instructions repeated until a condition is met
  • Sequential structures form the backbone of most algorithms and programs
  • What type of programming structure is used to calculate the area of a rectangle in a simple program?
    Sequential structure
  • What are programming constructs called where the execution of instructions depends on a condition being true or false?
    Selection structures
  • What type of programming structure is used to determine if a number is positive or negative?
    Selection structure
  • Iteration structures repeat instructions until a specific condition is met or a certain number of times.

    True
  • In a for loop, the loop variable 'i' increases by 1 in each iteration.

    True
  • Sequential structures execute instructions from top to bottom.

    True
  • What are the values of length and width in the example program to calculate the area of a rectangle?
    5 and 3
  • A common example of a selection structure is the if-else
  • A common example of an iteration structure is the for loop
  • What are the three basic programming constructs mentioned in the study material?
    Sequential, selection, iteration