Study

Pseudocodes - Loops

  •   0%
  •  0     0     0

  • Error? Output?
    x: 1→3→5→7 stop ⇒ 7.
  • Output? Error?
    x=8 ⇒ medium.
  • Error? Output?
    Missing END FOR. Intended total = 1+2+3 = 6.
  • Output?
    Uses comparison (=) correctly; x=5 ⇒ Not ten.
  • Error? Output?
    9
  • Error? Output?
    Off-by-one (should go to n). As is: 112*3 = 6.
  • DIV(31,4)
    7
  • Flowchart symbol
    Input/ Output
  • MOD(12,5)
    Remainder, 2
  • Error? Output?
    strings ⇒ 23
  • Flowchart symbol
    Decision
  • Output?
    3 + (2*2) = 7
  • Error? Output?
    (2+3)*2 = 10 ⇒ yes.
  • Error? Output?
    Adds only odds 1+3+5 = 9.
  • Error? Output?
    Case-sensitive compare ⇒ No.
  • Error? Output?
    Division by zero error. (No output; runtime error.)
  • Flowchart symbol
    Process
  • Output?
    area = 3.142*4 = 12.568.
  • Error or output?
    Missing i ← i + 1 ⇒ infinite loop. Corrected output would be 1 2.
  • Flowchart symbol
    Subroutine
  • Error? Output?
    s not initialized. If s starts at 0, sum = 15 → 15.
  • Flowchart symbol
    Terminator/ Start / Stop