Week 6 Lab
Q&A on Material
- while and do while keywords
- boolean flags
- for loops – not covered in lab, but available for midterm review
Sign in to lab!
Idioms Related to Iterative Statements
Take a look at the idioms related to basic loop (iterative) statements:
Exercises
Walk through these exercises and complete them as a group (if time allows).
Tracing
Determine the output of this program by tracing its execution manually.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int x = 0;
int y = 1;
while (!((x % 5 == 0) && (y % 64 == 0)))
{
x++;
y *= 2;
}
cout << x << " " << y << endl;
return 0;
}
Coding
Open-ended Help
Any students with questions may stay after to get help. Please ask questions! Anyone else may leave at this stage.