Week 4: Loops
Learning objectives:
Upon finishing this learning module, you should be able to:- Identify strategies for controlling repetition - counters, sentinels & flags
- Write programs that use repetition structures to solve problems
- Navigate directories and compile files from the command line.
Deadlines This Week:
- Monday 11:59PM - Assignment 3
- Fri 11:59PM - CPPLab Basic Loops
- Fri 11:59PM - CPPLab Loops 2
- Sat 11:59PM - CPPLab Nested Loops
Classroom Schedule:
- Monday
-
- Command Line Compiling and Running - See Class files link below for instructions
- Tuesday
-
- Loops
- Ch 5.1-5.3
- Loop styles & strategies
- Ch 5.4-5.5, and 5.6-5.9
- CppLab Basic Loops
- CppLab Loops 2
- Wed
-
- Nested Loops
- Ch 5.10-5.13, 15.15
- CppLab Nested Loops
- Fri
-
- String Basics (Read Ch 4.8, 10.2, you can stop at 10.2.10)
- String Practice WS
Online Activity Outline:
Working on the Command Line
In parallel with the assignment, do the following activities to start getting familiar with the command line. Before there were windows and mice, the way we interacted with computers was all based on text input into consoles (like the programs we are currently writing). Many tools programmers use work on the command line (behind the scenes, QtCretaor is using text based commands to call the compiler) - learning to use the command line is essential.-
This video demonstrates the basics:
- This Command Line Guide provides detailed instructions for how to open a command prompt, set up the path, navigate, and use g++. Using a QtCreator project, try building and running the code from the command prompt as shown in the video.
- For a more detailed treatment read either this Windows command line guide (up to 2.6). or this Mac/Linux command line guide (up to 3.5).
Loops
- Read Ch 5.1-5.3. This video introduces the key ideas:
- Do CPPLab Basic Loops
- Read Ch 5.4-5.5 and 5.6-5.9 and watch this video:
Do CPPLab Loops 2 - Read Ch 5.10-5.13, 15.15 and watch this video:
- Do Nested Loops CPPLab
- Read the rest of Ch 5.
- Work on the assingment while you start preparing for next week by reading about strings below.
String Intro
-
Read Ch 4.8 and 10.2 (you can stop at 10.2.10). Watch this video that introduces the basics:
- Go look up string on cplusplus.com - use the search box at the top, and do a search for "string". Then click on one of the functions, like "insert" and skim the documentation. You need to start getting used to looking up things - most programmers do that on the web instead of in textbooks, so start practicing!
- Do the StringPractice worksheet from the Classroom files link below. Like before, try to predict the output for each statement then test it and see if you were correct.
Extra Info:
Learncpp.com
This online tutorial covers some of the same ground as the Liang readings:
LearnCpp.com 5.5 to 5.8 and 0.4
LearnCpp.com 5.5 to 5.8 and 0.4
Classroom slides/examples:
Directory of files from the weekRight click files and save to your computer