CSCI 102 - Fall 2023 Fundamentals of Computation

Week 7 Lab

Q&A on Material

Sign in to lab!

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

#include <iostream>
using namespace std;

int main()
{
    int n = 15;
    int total = 0;
    for(int i = 1; i < n; i+=2)
    {
        if (i % 3 == 0)
        {
             total += i;
        }
    }
    for ( ; total > 0; total--)
    {
          n++;
          if(total % 5 == 0)
          {
               break;
          }
    }
    return 0;
}

Solution

Coding

cpp/cs102/selection/tallest
cpp/cs102/selection/pos-neg-balance
cpp/cs102/distributed-and/increasing

Open-ended Help

Any students with questions may stay after to get help. Anyone else may leave at this stage.