{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "962ffbca-649e-4de3-83d7-482538741f52",
   "metadata": {},
   "source": [
    "# Chapter Review\n",
    "\n",
    "- Note that the course policy is that you should not use generative AI\n",
    "  without authorization. If you are suspected to have used generative AI\n",
    "  and not able to explain/reproduce your work when requested, all your\n",
    "  **related assignments throughout the semester will be regraded as 0.**\n",
    "- Prepare this assignment using a Word document.\n",
    "- Number and write answers under each question.\n",
    "- Paste code screenshots when required.\n",
    "\n",
    "You are encourage to keep your test code in the project. To do that:\n",
    "\n",
    "- Create a dotnet console app project ({ref}`create-project`), if you\n",
    "  have not done that, in your *USERNAME*/workspace/introcscs directory; called it\n",
    "  **Ch05ForLoop**.\n",
    "- Place your test code in methods to be called from the Main method. Name your\n",
    "  methods properly.\n",
    "\n",
    "1.  When you have nested `for` loops, and you reach the bottom of the *body* of the\n",
    "    *inner* loop, where does execution go next?\n",
    "\n",
    "2.  What happens when you omit the condition in a `for` loop?\n",
    "\n",
    "    Explain and try it out in csharprepl or VS Code and paste the results here.\n",
    "\n",
    "3.  In the heading of a `for` loop, how do you initialize or update\n",
    "    several variables?\n",
    "\n",
    "4.  Rewrite\n",
    "\n",
    "        num /= 2;\n",
    "\n",
    "    equivalently without the operand `/=`.\n",
    "\n",
    "5.  Rewrite\n",
    "\n",
    "        bigName = bigName - 10;\n",
    "\n",
    "    with a statement that only includes `bigName` once.\n",
    "\n",
    "6.  Distinguish the effects of these two statements:\n",
    "\n",
    "        x-=2;\n",
    "\n",
    "        x=-2;\n",
    "\n",
    "7.  What is printed?\n",
    "\n",
    "        Console.WriteLine(\"12345678\");\n",
    "        for( int p = 1; p < 6; p++) {\n",
    "            string formatStr = \"{0:F\" + p + \"}\";\n",
    "            Console.WriteLine(formatStr, 1.2345678);\n",
    "        }\n",
    "\n",
    "    Explain, then paste here the screenshot of the results of you testing it in csharprepl or VS Code.\n",
    "\n",
    "8.  What is printed? (Just “,4” has been inserted.)\n",
    "\n",
    "        Console.WriteLine(\"12345678\");\n",
    "        for( int p = 1; p < 6; p++) {\n",
    "            string formatStr = \"{0,4:F\" + p + \"}\";\n",
    "            Console.WriteLine(formatStr, 1.2345678);\n",
    "        }\n",
    "\n",
    "    Explain, then paste here the screenshot of the results of you testing it in csharprepl or VS Code.\n",
    "\n",
    "9.  What is printed?\n",
    "\n",
    "        Console.WriteLine(\"123456\");\n",
    "        for( int w = 6; w >= -6; w -= 4) {\n",
    "            string formatStr = \"{0,\" + w + \"}|\";\n",
    "            Console.WriteLine(formatStr, \"here\");\n",
    "        }\n",
    "\n",
    "    Explain, then paste here the screenshot of the results of you testing it in csharprepl or VS Code.\n",
    "\n",
    "10. Even if you want to process every element of a sequence, what would keep\n",
    "    you from using a `foreach` loop?\n",
    "\n",
    "% #. May you legally omit the initialization part of a `for` loop?"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}
