{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "51fe5a46-c222-4ea2-ab17-c2a19acfca45",
   "metadata": {},
   "source": "# Preview Questions\n\nComplete these questions **before** class to prepare for the chapter.\nUse the dropdowns to check your answers.\n"
  },
  {
   "cell_type": "markdown",
   "id": "23d75cc1-a6b4-4dc2-b73c-04a3206d3596",
   "metadata": {},
   "source": "## True or False\n\n**1.** A `for` loop must always count upward.\n\n```{dropdown} Answer\n**False** — The update expression can decrement: `i--` is perfectly valid.\n```\n\n**2.** The `break` statement exits the nearest enclosing loop.\n\n```{dropdown} Answer\n**True** — `break` jumps to the statement after the closest loop.\n```\n\n**3.** The body of a `while` loop may never execute if the condition is false initially.\n\n```{dropdown} Answer\n**True** — The condition is checked before the first iteration.\n```\n\n**4.** A `for` loop and a `while` loop can always be used interchangeably.\n\n```{dropdown} Answer\n**True** — Every `for` loop can be rewritten as a `while` loop and vice versa.\n```\n\n**5.** `continue` skips the rest of the loop body and moves to the next iteration.\n\n```{dropdown} Answer\n**True** — `continue` jumps to the loop's update/condition check.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "b0434c73-e5fc-477a-bf4f-fccb2e977d64",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** How many times does `for (int i = 0; i < 5; i++)` execute its body?\n\na) 4  \nb) 5  \nc) 6  \nd) Infinite\n\n```{dropdown} Answer\n**b) 5** — i takes values 0,1,2,3,4 — five iterations.\n```\n\n**2.** Which loop type is best when the number of iterations is unknown in advance?\n\na) for  \nb) foreach  \nc) while  \nd) do-while\n\n```{dropdown} Answer\n**c) while** — `while` tests a condition each iteration without requiring a known count.\n```\n\n**3.** What does `continue` do inside a loop body?\n\na) Exits the loop  \nb) Restarts the program  \nc) Skips to the next iteration  \nd) Pauses execution\n\n```{dropdown} Answer\n**c) Skips to the next iteration** — `continue` skips remaining statements in the current iteration.\n```\n\n**4.** A `do-while` loop differs from a `while` loop in that:\n\na) It uses different syntax only  \nb) It always executes the body at least once  \nc) It cannot use `break`  \nd) It only works with integers\n\n```{dropdown} Answer\n**b) It always executes the body at least once** — The body runs before the condition is first evaluated.\n```\n\n**5.** What value does `i` hold after `for (int i = 0; i < 3; i++) {}`?\n\na) 2  \nb) 3  \nc) 4  \nd) 0\n\n```{dropdown} Answer\n**b) 3** — The loop exits when i == 3, so i is 3 after the loop ends.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "7ea7f012-2ca7-47cb-bf98-065ddf7df8bf",
   "metadata": {},
   "source": "```{rubric} Footnotes\n```\n"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
