This commit is contained in:
2025-11-14 20:08:33 +03:30
parent c691372cab
commit f96cc9fe86
11 changed files with 248 additions and 163 deletions
@@ -1,63 +0,0 @@
> [!info] Brief description
> This page lists the **workshop questions** for this topic and provides **downloadable official solutions**.
> These questions are meant to help you apply the concepts learned in class through hands-on coding exercises.
---
> [!tip] How to use this page
> - Start by attempting each question on your own.
> - Use the official solutions only to review and learn better approaches.
> - If something doesnt make sense, **ask a TA** during or after the session.
> - Check the [Q&A page](../resources/qa.md) for common questions and clarifications.
---
## 📦 Download All Solutions
- **All official solutions (zip):** [Download all official solutions](./workshops/01-basics-data-types/official-solutions.zip)
---
## 🧾 Official Questions & Solutions
| Question # | Title / Short Description | Question (Download) | Official Solution (Download) |
| ---------- | ------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------- |
| Q1 | Simple I/O and variables — read two numbers and print the sum | [Download PDF](./workshops/01-q1-question.pdf) | [01-q1-solution.cpp](./workshops/01-q1-solution.cpp) |
| Q2 | Type conversion — integer division vs floating point | [Download PDF](./workshops/01-q2-question.pdf) | [01-q2-solution.cpp](./workshops/01-q2-solution.cpp) |
| Q3 | Using `<cmath>` — compute and format results | [Download PDF](./workshops/01-q3-question.pdf) | [01-q3-solution.cpp](./workshops/01-q3-solution.cpp) |
| Q4 | Edge cases & input validation | [Download PDF](./workshops/01-q4-question.pdf) | [01-q4-solution.cpp](./workshops/01-q4-solution.cpp) |
> [!note] Not available yet?
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
---
## ❓ Q&A and Support
> [!question] Got stuck or confused?
> If something in a question or solution is unclear:
> - Revisit the lecture notes and workshop slides.
> - Check the [Q&A page](../resources/qa.md) for clarifications.
> - Ask your TA — thats what were here for.
- [Topic Q&A](../resources/qa.md)
- [Workshop Slides](./workshops/01-basics-data-types/slides.pdf)
---
## 🙏 Acknowledgements
> [!success] Special thanks
> These materials were created collaboratively to support your learning.
> - You are encouraged to use and adapt the solutions **for learning**, not copying.
> - If you find an error or have a better solution, you can suggest an improvement.
> - TA and instructor feedback will be added over time.
---
## ⚖️ Licensing & Usage
> [!important] Usage note
> Official workshop solutions are for **educational use only**. Please do not repost them publicly or use them in ways that violate course policy.
@@ -9,24 +9,29 @@
> - Start by attempting each question on your own. > - Start by attempting each question on your own.
> - Use the official solutions only to review and learn better approaches. > - Use the official solutions only to review and learn better approaches.
> - If something doesnt make sense, **ask a TA**. > - If something doesnt make sense, **ask a TA**.
> - Check the [Q&A page](../resources/qa.md) for common questions and clarifications.
--- ---
## 📦 Download All Solutions ## 📦 Download All Questions and Solutions
- **All official solutions (zip):** [Download all official solutions](./workshops/01-basics-data-types/official-solutions.zip) - **All questions (zip):** [Download all questions](https://drive.google.com/file/d/1SaM7dICduui9NjqiqHTU-5L_AftlvoHE/view?usp=drive_link)
- **All official solutions (zip):** [Download all official solutions](https://drive.google.com/file/d/1V3GwUGKBhvXT5Ab1fDy7Ek27x-1Q4Nny/view?usp=drive_link)
--- ---
## 🧾 Official Questions & Solutions ## 🧾 Official Questions & Solutions
| Question # | Title / Short Description | Question (Download) | Official Solution (Download) | | Question # | Question (Download) | Official Solution (Download) | Additional Notes |
| ---------- | ------------------------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------- | | ---------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------- |
| Q1 | Simple I/O and variables — read two numbers and print the sum | [Download PDF](./workshops/01-q1-question.pdf) | [01-q1-solution.cpp](./workshops/01-q1-solution.cpp) | | 01 | [Download PDF](https://drive.google.com/file/d/1mQd1oFr605IYz8SFA0u07_tt8w5ibEIp/view?usp=sharing) | [Download Solution (zip)](https://drive.google.com/file/d/1suqDVN3OtZDS4EnfJInVoM1tal6QWUit/view?usp=drive_link) | |
| Q2 | Type conversion — integer division vs floating point | [Download PDF](./workshops/01-q2-question.pdf) | [01-q2-solution.cpp](./workshops/01-q2-solution.cpp) | | 02 | [Download PDF](https://drive.google.com/file/d/1mv7Mp3gxYSK1r-OH5h88ueJMSUCSC-Gc/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1UUlwNpQvdQU7S_h_azYSAudxsZKi6NtW/view?usp=drive_link) | |
| Q3 | Using `<cmath>` — compute and format results | [Download PDF](./workshops/01-q3-question.pdf) | [01-q3-solution.cpp](./workshops/01-q3-solution.cpp) | | 03 | [Download PDF](https://drive.google.com/file/d/1FT1YFfGDekytEDnRd2wNThTNRIJ0Gtvx/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1vtC4GwdEd2Q3YSos9FWzJeYEJy_4gwuu/view?usp=drive_link) | |
| Q4 | Edge cases & input validation | [Download PDF](./workshops/01-q4-question.pdf) | [01-q4-solution.cpp](./workshops/01-q4-solution.cpp) | | 04 | [Download PDF](https://drive.google.com/file/d/1ql1-JOaNArnH4aHjOvZkmWqYyDFcAKsV/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/17gfm6Ocl1RrA57FLJC4DS2-hn_gvVfFZ/view?usp=drive_link) | |
| 05 | [Download PDF](https://drive.google.com/file/d/1ev7SrFO4kdSkPn7ZX8z148QptLDJVpmG/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1OuI3u81ll6-GKARoVYUEjabFaHTINyKm/view?usp=drive_link) | |
| 06 | [Download PDF](https://drive.google.com/file/d/1cSJwqGXNXzu8foMDh9585VM6MzkQ1TKH/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1alVdHcCxrTcCIH0wZbS6CDCCmDclNaRH/view?usp=drive_link) | |
| 07 | [Download PDF](https://drive.google.com/file/d/1klayxpRC-EIC_E7S_-SnOojA3lUmuNrZ/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/11pjUFIcS83qcy7Ac5l8DHL-EEgkVO5NE/view?usp=drive_link) | |
| 08 | [Download PDF](https://drive.google.com/file/d/18yKwoek6fmrSaUZWF79rrIn5BGS0GUIK/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1OuPGpJgkfB8BHoDlMaTDnlRn9NhyLDdA/view?usp=drive_link) | |
| 09 | [Download PDF](https://drive.google.com/file/d/1i9XugaK_iqJlgaWemrrZbYxNlGmXsm9d/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1Ppni5K6EQZF2mqVR_u6dq7NyXS-eHZ-1/view?usp=drive_link) | |
| 10 | [Download PDF](https://drive.google.com/file/d/1ihsQfgfZp7wWRt33lm3-ZPAnkQ0I5bv4/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/110ieA_9qNIyvweunLKChcQHcraSeoWI6/view?usp=drive_link) | |
> [!note] Not available yet? > [!note] Not available yet?
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA. > Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
@@ -38,25 +43,11 @@
> [!question] Got stuck or confused? > [!question] Got stuck or confused?
> If something in a question or solution is unclear: > If something in a question or solution is unclear:
> - Revisit the lecture notes and workshop slides. > - Revisit the lecture notes and workshop slides.
> - Check the [Q&A page](../resources/qa.md) for clarifications.
> - Ask your TA — thats what were here for. > - Ask your TA — thats what were here for.
- [Topic Q&A](../resources/qa.md) - [Topic Q&A](01-topics/01-problem-solving/3-Q&A.md)
- [Workshop Slides](./workshops/01-basics-data-types/slides.pdf) - [TA Slides](01-topics/01-problem-solving/5-TASlides.md)
- [Professor Slides](../lectures/01-data-types/professor-slides.pdf)
--- ---
## 🙏 Acknowledgements
> [!success] Special thanks
> These materials were created collaboratively to support your learning.
> - You are encouraged to use and adapt the solutions **for learning**, not copying.
> - If you find an error or have a better solution, you can suggest an improvement.
> - TA and instructor feedback will be added over time.
---
## ⚖️ Licensing & Usage ## ⚖️ Licensing & Usage
> [!important] Usage note > [!important] Usage note
@@ -0,0 +1,6 @@
## 🔗 Download
- [Download PDF](https://drive.usercontent.google.com/u/0/uc?id=1_e2c5by8f2r-sWSpjnioXWm16mUZFTtp&export=download)
## View PDF Online
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1_e2c5by8f2r-sWSpjnioXWm16mUZFTtp&export=download" width="100%" height="700px" frameborder="0"> </iframe>
@@ -8,57 +8,42 @@
> [!tip] How to use this page > [!tip] How to use this page
> - Start by attempting each question on your own. > - Start by attempting each question on your own.
> - Use the official solutions only to review and learn better approaches. > - Use the official solutions only to review and learn better approaches.
> - If something doesnt make sense, **ask a TA** during or after the session. > - If something doesnt make sense, **ask a TA**.
> - Check the [Q&A page](../resources/qa.md) for common questions and clarifications.
--- ---
## 📦 Download All Solutions ## 📦 Download All Questions and Solutions
- **All official solutions (zip):** [Download all official solutions](./workshops/01-basics-data-types/official-solutions.zip) - **All questions (zip):** [Download all questions](https://drive.google.com/file/d/1SaM7dICduui9NjqiqHTU-5L_AftlvoHE/view?usp=drive_link)
- **All official solutions (zip):** [Download all official solutions](https://drive.google.com/file/d/1V3GwUGKBhvXT5Ab1fDy7Ek27x-1Q4Nny/view?usp=drive_link)
--- ---
## 🧾 Official Questions & Solutions ## 🧾 Official Questions & Solutions
| Question # | Title / Short Description | Question (Download) | Official Solution (Download) | | Question # | Question (Download) | Official Solution (Download) | Additional Notes |
|------------|---------------------------------------------------------------|---------------------------------------------------------------|------------------------------------------------------------------| | ---------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------- |
| Q1 | Simple I/O and variables — read two numbers and print the sum | [Download PDF](./workshops/01-q1-question.pdf) | [01-q1-solution.cpp](./workshops/01-q1-solution.cpp) | | 01 | [Download PDF](https://drive.google.com/file/d/1mQd1oFr605IYz8SFA0u07_tt8w5ibEIp/view?usp=sharing) | [Download Solution (zip)](https://drive.google.com/file/d/1suqDVN3OtZDS4EnfJInVoM1tal6QWUit/view?usp=drive_link) | |
| Q2 | Type conversion — integer division vs floating point | [Download PDF](./workshops/01-q2-question.pdf) | [01-q2-solution.cpp](./workshops/01-q2-solution.cpp) | | 02 | [Download PDF](https://drive.google.com/file/d/1mv7Mp3gxYSK1r-OH5h88ueJMSUCSC-Gc/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1UUlwNpQvdQU7S_h_azYSAudxsZKi6NtW/view?usp=drive_link) | |
| Q3 | Using `<cmath>` — compute and format results | [Download PDF](./workshops/01-q3-question.pdf) | [01-q3-solution.cpp](./workshops/01-q3-solution.cpp) | | 03 | [Download PDF](https://drive.google.com/file/d/1FT1YFfGDekytEDnRd2wNThTNRIJ0Gtvx/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1vtC4GwdEd2Q3YSos9FWzJeYEJy_4gwuu/view?usp=drive_link) | |
| Q4 | Edge cases & input validation | [Download PDF](./workshops/01-q4-question.pdf) | [01-q4-solution.cpp](./workshops/01-q4-solution.cpp) | | 04 | [Download PDF](https://drive.google.com/file/d/1ql1-JOaNArnH4aHjOvZkmWqYyDFcAKsV/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/17gfm6Ocl1RrA57FLJC4DS2-hn_gvVfFZ/view?usp=drive_link) | |
> [!note] Not available yet? > [!note] Not available yet?
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA. > Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
--- ---
## ❓ Q&A and Support ## ❓ Q&A and Support
> [!question] Got stuck or confused? > [!question] Got stuck or confused?
> If something in a question or solution is unclear: > If something in a question or solution is unclear:
> - Revisit the lecture notes and workshop slides. > - Revisit the lecture notes and workshop slides.
> - Check the [Q&A page](../resources/qa.md) for clarifications.
> - Ask your TA — thats what were here for. > - Ask your TA — thats what were here for.
- [Topic Q&A](../resources/qa.md) - [Topic Q&A](01-topics/02-basics-and-data-types/3-Q&A.md)
- [Workshop Slides](./workshops/01-basics-data-types/slides.pdf) - [Professor Slides](01-topics/02-basics-and-data-types/4-ProfessorSlides.md)
- [Professor Slides](../lectures/01-data-types/professor-slides.pdf) - [TA Slides](01-topics/02-basics-and-data-types/5-TASlides.md)
--- ---
## 🙏 Acknowledgements
> [!success] Special thanks
> These materials were created collaboratively to support your learning.
> - You are encouraged to use and adapt the solutions **for learning**, not copying.
> - If you find an error or have a better solution, you can suggest an improvement.
> - TA and instructor feedback will be added over time.
---
## ⚖️ Licensing & Usage ## ⚖️ Licensing & Usage
> [!important] Usage note > [!important] Usage note
> Official workshop solutions are for **educational use only**. Please do not repost them publicly or use them in ways that violate course policy. > Official assignment solutions are for **educational use only**. Please do not repost them publicly or use them in ways that violate course policy.
@@ -9,34 +9,29 @@
> - Start by attempting each question on your own. > - Start by attempting each question on your own.
> - Use the official solutions only to review and learn better approaches. > - Use the official solutions only to review and learn better approaches.
> - If something doesnt make sense, **ask a TA**. > - If something doesnt make sense, **ask a TA**.
> - Check the [Q&A page](../resources/qa.md) for common questions and clarifications.
--- ---
| Concept | Example Keywords | ## 📦 Download All Questions and Solutions
| -------------- | ----------------------------- |
| Input/Output | `cin`, `cout`, `setprecision` |
| Integer math | `/`, `%`, precedence |
| Floating-point | rounding, precision |
| Math library | `sqrt`, `pow`, `abs` |
- **All questions (zip):** [Download all questions](https://drive.google.com/file/d/1SaM7dICduui9NjqiqHTU-5L_AftlvoHE/view?usp=drive_link)
- **All official solutions (zip):** [Download all official solutions](https://drive.google.com/file/d/1V3GwUGKBhvXT5Ab1fDy7Ek27x-1Q4Nny/view?usp=drive_link)
--- ---
## 📦 Download All Solutions
- **All official solutions (zip):** [Download all official solutions](./workshops/01-basics-data-types/official-solutions.zip)
---
## 🧾 Official Questions & Solutions ## 🧾 Official Questions & Solutions
| Question # | Title / Short Description | Question (Download) | Official Solution (Download) | | Question # | Question (Download) | Official Solution (Download) | Additional Notes |
|------------|---------------------------------------------------------------|---------------------------------------------------------------|------------------------------------------------------------------| | ---------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------- |
| Q1 | Simple I/O and variables — read two numbers and print the sum | [Download PDF](./workshops/01-q1-question.pdf) | [01-q1-solution.cpp](./workshops/01-q1-solution.cpp) | | 01 | [Download PDF](https://drive.google.com/file/d/1mQd1oFr605IYz8SFA0u07_tt8w5ibEIp/view?usp=sharing) | [Download Solution (zip)](https://drive.google.com/file/d/1suqDVN3OtZDS4EnfJInVoM1tal6QWUit/view?usp=drive_link) | |
| Q2 | Type conversion — integer division vs floating point | [Download PDF](./workshops/01-q2-question.pdf) | [01-q2-solution.cpp](./workshops/01-q2-solution.cpp) | | 02 | [Download PDF](https://drive.google.com/file/d/1mv7Mp3gxYSK1r-OH5h88ueJMSUCSC-Gc/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1UUlwNpQvdQU7S_h_azYSAudxsZKi6NtW/view?usp=drive_link) | |
| Q3 | Using `<cmath>` — compute and format results | [Download PDF](./workshops/01-q3-question.pdf) | [01-q3-solution.cpp](./workshops/01-q3-solution.cpp) | | 03 | [Download PDF](https://drive.google.com/file/d/1FT1YFfGDekytEDnRd2wNThTNRIJ0Gtvx/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1vtC4GwdEd2Q3YSos9FWzJeYEJy_4gwuu/view?usp=drive_link) | |
| Q4 | Edge cases & input validation | [Download PDF](./workshops/01-q4-question.pdf) | [01-q4-solution.cpp](./workshops/01-q4-solution.cpp) | | 04 | [Download PDF](https://drive.google.com/file/d/1ql1-JOaNArnH4aHjOvZkmWqYyDFcAKsV/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/17gfm6Ocl1RrA57FLJC4DS2-hn_gvVfFZ/view?usp=drive_link) | |
| 05 | [Download PDF](https://drive.google.com/file/d/1ev7SrFO4kdSkPn7ZX8z148QptLDJVpmG/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1OuI3u81ll6-GKARoVYUEjabFaHTINyKm/view?usp=drive_link) | |
| 06 | [Download PDF](https://drive.google.com/file/d/1cSJwqGXNXzu8foMDh9585VM6MzkQ1TKH/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1alVdHcCxrTcCIH0wZbS6CDCCmDclNaRH/view?usp=drive_link) | |
| 07 | [Download PDF](https://drive.google.com/file/d/1klayxpRC-EIC_E7S_-SnOojA3lUmuNrZ/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/11pjUFIcS83qcy7Ac5l8DHL-EEgkVO5NE/view?usp=drive_link) | |
| 08 | [Download PDF](https://drive.google.com/file/d/18yKwoek6fmrSaUZWF79rrIn5BGS0GUIK/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1OuPGpJgkfB8BHoDlMaTDnlRn9NhyLDdA/view?usp=drive_link) | |
| 09 | [Download PDF](https://drive.google.com/file/d/1i9XugaK_iqJlgaWemrrZbYxNlGmXsm9d/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/1Ppni5K6EQZF2mqVR_u6dq7NyXS-eHZ-1/view?usp=drive_link) | |
| 10 | [Download PDF](https://drive.google.com/file/d/1ihsQfgfZp7wWRt33lm3-ZPAnkQ0I5bv4/view?usp=drive_link) | [Download Solution (zip)](https://drive.google.com/file/d/110ieA_9qNIyvweunLKChcQHcraSeoWI6/view?usp=drive_link) | |
> [!note] Not available yet? > [!note] Not available yet?
> Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA. > Some solutions will be uploaded after the workshop or assignment deadline. Check back later or ask your TA.
@@ -48,25 +43,12 @@
> [!question] Got stuck or confused? > [!question] Got stuck or confused?
> If something in a question or solution is unclear: > If something in a question or solution is unclear:
> - Revisit the lecture notes and workshop slides. > - Revisit the lecture notes and workshop slides.
> - Check the [Q&A page](../resources/qa.md) for clarifications.
> - Ask your TA — thats what were here for. > - Ask your TA — thats what were here for.
- [Topic Q&A](../resources/qa.md) - [Topic Q&A](01-topics/02-basics-and-data-types/3-Q&A.md)
- [Workshop Slides](./workshops/01-basics-data-types/slides.pdf) - [Professor Slides](01-topics/02-basics-and-data-types/4-ProfessorSlides.md)
- [Professor Slides](../lectures/01-data-types/professor-slides.pdf) - [TA Slides](01-topics/02-basics-and-data-types/5-TASlides.md)
--- ---
## 🙏 Acknowledgements
> [!success] Special thanks
> These materials were created collaboratively to support your learning.
> - You are encouraged to use and adapt the solutions **for learning**, not copying.
> - If you find an error or have a better solution, you can suggest an improvement.
> - TA and instructor feedback will be added over time.
---
## ⚖️ Licensing & Usage ## ⚖️ Licensing & Usage
> [!important] Usage note > [!important] Usage note
@@ -8,10 +8,6 @@ For example:
> - `int x = 5;` > - `int x = 5;`
> - `float y = 5.25;` > - `float y = 5.25;`
📚 **Read more:**
- [Professor Slides](https://chatgpt.com/Slides/Topic.pdf)
- [Workshop Slides](https://chatgpt.com/Workshop/Workshop.pdf)
- [External Resource](https://cplusplus.com/doc/tutorial/variables/)
--- ---
@@ -21,8 +17,3 @@ For example:
> [!info] Answer > [!info] Answer
> Semicolons mark the end of a statement in C++. They help the compiler understand where one command finishes and the next begins. Without it, the compiler throws an error. > Semicolons mark the end of a statement in C++. They help the compiler understand where one command finishes and the next begins. Without it, the compiler throws an error.
📚 **Read more:**
- [Professor Slides](https://chatgpt.com/Slides/Topic.pdf)
- [External Resource](https://www.geeksforgeeks.org/basics-of-cpp/)
@@ -0,0 +1,13 @@
## 🔗 Download
- [Download PDF - Lecture 00](https://drive.usercontent.google.com/u/0/uc?id=1w74gIFxcbs1syPYu0-0a-FotyODGZUre&export=download)
- [Download PDF - Lecture 01](https://drive.usercontent.google.com/u/0/uc?id=1FH66cV52t3YQtaCpUlsx0ulSdW-oZNeH&export=download)
## View PDF Online
### Lecture 00
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1w74gIFxcbs1syPYu0-0a-FotyODGZUre&export=download" width="100%" height="700px" frameborder="0"> </iframe>
---
### Lecture 01
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1FH66cV52t3YQtaCpUlsx0ulSdW-oZNeH&export=download" width="100%" height="700px" frameborder="0"> </iframe>
@@ -0,0 +1,11 @@
## 🔗 Download
- [Download PDF Part 1: Computer 101](https://drive.usercontent.google.com/u/0/uc?id=1h4Yk1D-PgJHz0mgqiXTq_klk40LF9B_G&export=download)
- [Download PDF Part 2: Data Types](https://drive.usercontent.google.com/u/0/uc?id=1d5GhbYiw1JVPTZDxDrBKPYX-r6m0qqol&export=download)
## View PDF Online
### Computer 101
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1h4Yk1D-PgJHz0mgqiXTq_klk40LF9B_G&export=download" width="100%" height="700px" frameborder="0"> </iframe>
### Data Types
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1d5GhbYiw1JVPTZDxDrBKPYX-r6m0qqol&export=download" width="100%" height="700px" frameborder="0"> </iframe>
@@ -0,0 +1,157 @@
# 🧭 Topic: C++ Control Structures
> [!info] Quick Overview
>
---
## 📌 Covered in This Topic
### Part 1 - Conditions
- Introduction to Control Structures
- What are _control structures_ and why they matter
- How conditions allow decision-making in programs
- Types of control flow in C++:
- Sequential
- Selection (branching — **this lectures focus**)
- Iteration (to be covered later)
- 2. Operators and Their Categories
- Overview: Operators as tools for computation and logic
- Main categories relevant to conditions:
- **Arithmetic operators** (`+`, `-`, `*`, `/`, `%`) for expressions inside conditions
- **Comparison / Relational operators** ` ==, !=, <, >, <=, >=`
- Logical operators (`&&`, `||`, `!`)
- Bitwise operators (intro only) (`&`, `|`, `^`, `~`, `<<`, `>>`)
- Distinguish between _bitwise_ and _logical_ operations
- Simple binary truth table demonstration
- Boolean Expressions and Truth Evaluation
- How C++ evaluates boolean expressions (`true`, `false`, `0`, `non-zero`)
- Short-circuit evaluation with `&&` and `||`
- Expression combinations and nested conditions
- Boolean variables and expressions (`bool is_valid = age > 18;`)
- Conditional Statements
- The `if` Statement**
- Basic syntax and flow
- Single-statement vs block (`{}`) forms
- Recommended: **always use braces** for clarity and safety
- Readability and indentation rules
- if...else` and `else if Chains
- Multi-condition logic
- Execution flow and exclusivity (only one branch executes)
- Common pitfalls (missing `else`, overlapping conditions)
- Nested `if` Statements
- When to nest vs when to restructure
- Clean and readable formatting examples
- Introduce the idea of _early return_ or _guard clauses_ as clean code alternatives
- The Ternary Operator (`?:`)**
- Syntax and usage
- Example: `result = (x > 0) ? 1 : -1;`
- When to use vs when not to use
- _“Short-hand if”_ — only for **simple assignments or expressions**
- Readability trade-offs
- The `switch` Statement
- Purpose and syntax
- Supported data types:
- `int`, `char`, `enum`, `bool` (and C++11 `constexpr` integral types)
- ⚠️ Not supported: `float`, `double`, `string`
- **Case labels** and the need for `break`
- **Default** case and its importance
- Fall-through behavior (intentional vs accidental)
- Example: menu-based program with `switch`
- Operator Precedence and Associativity**
- Order in which operators are evaluated
- Why parentheses improve readability and prevent bugs
- Quick reference table for comparison, logical, and arithmetic operators
- Example comparisons showing subtle precedence mistakes
- Clean Code and Best Practices**
- Always use braces `{}` even for single statements
- Align and indent consistently
- Use descriptive variable and condition names (`if (is_authenticated)` not `if (x)`)
- Avoid deeply nested conditions (refactor with functions or early returns)
- Comment _why_ not _what_
- Test all branches (especially edge cases and default paths)
---
### Part 2 - Loops
- **Introduction to Iteration**
- Why repetition is needed in programs
- The concept of control flow — branching vs looping
- **The `while` Loop**
- Syntax and structure
- Flow of control in `while`
- Typical use cases: input validation, sentinel-controlled loops
- Common pitfalls (infinite loops, missing updates)
- **The `do-while` Loop**
- Difference between `while` and `do-while` (post-test vs pre-test)
- When to use `do-while` (menus, repeated input until valid)
- **The `for` Loop**
- Syntax and structure (`initialization`, `condition`, `update`)
- Iterating over numeric ranges
- Loop variable scope and lifetime
- Variations: multiple initializations, empty components
- Using `for` for counting and fixed iterations
- **Loop Control Statements**
- `break` — exiting early
- `continue` — skipping to next iteration
- `return` in loops
- Discuss readability vs misuse of these
- **Nested Loops**
- How inner loops behave relative to outer loops
- Common examples: printing patterns, working with 2D arrays
- Complexity growth and performance intuition (Brief)
- **Loop Design Patterns**
- Counter-controlled loops
- Sentinel-controlled loops
- Flag-controlled loops
- Infinite loops with `break` condition
- **Order of Execution Recap**
- Loop initialization → condition check → body → update
- Flow diagrams to illustrate control
- **Best Practices and Clean Code**
- Avoid “magic numbers” — use constants in loop bounds
- Use meaningful variable names (`i`, `j` are fine for indices, otherwise be descriptive)
- Ensure loops have clear termination conditions
- Maintain consistent indentation and brace style
- **Debugging and Tracing Loops**
- Using print statements to track variables
- Recognizing off-by-one errors
## 📑 Slides & Materials
- 👨‍🏫 [Professor Slides (PDF)](./4-ProfessorSlides.md)
- 🧑‍🏫 [TA Workshop Slides (PDF)](./5-TASlides)
---
## 🛠️ Workshop & Assignments
- 💬 [Workshop Questions](./1-Workshop)
- 🧮 [Assignments](01-topics/01-problem-solving/2-Assignment.md)
- ❓ [Q&A and Common Issues](./3-Q&A.md)
---
## 🌐 Additional Resources
- [C++ Reference](https://cplusplus.com/reference/)
- [Learn C++](https://www.learncpp.com/)
- [Data Types in C++ (W3Schools)](https://www.w3schools.com/cpp/cpp_data_types.asp)
_Add more useful links here as the course progresses._
---
## ⏩ Navigation
- ⬅️ [Previous Topic: Problem Solving](../02-problem-solving/topic.md)
- ➡️ [Next Topic: Conditions & Loops](../04-conditions-loops/topic.md)
---
> [!tip] Tip
> If something doesnt make sense — **dont stay stuck alone**. Ask the TA to clarify it right away. Often, a quick question can save you a lot of time and frustration. Remember: if youre confused, chances are others are too.
@@ -0,0 +1,6 @@
## 🔗 Download
- [Download PDF](INSERT_DOWNLOAD_URL_HERE)
## View PDF Online
<iframe src="https://docs.google.com/gview?embedded=true&url=INSERT_DOWNLOAD_URL_HERE" width="100%" height="700px" frameborder="0"> </iframe>
@@ -0,0 +1,6 @@
## 🔗 Download
- [Download PDF](https://drive.google.com/file/d/1_e2c5by8f2r-sWSpjnioXWm16mUZFTtp/view?usp=sharing)
## View PDF Online
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.google.com/file/d/1_e2c5by8f2r-sWSpjnioXWm16mUZFTtp/view?usp=sharing" width="100%" height="700px" frameborder="0"> </iframe>