COP 3014 Recitation - Week 4

Loops and File Operations

  • First we'll go over for loops together
  • Take this program and modify it to execute the cout statement 5 times using a for loop
  • Change your program to execute the for loop 100 times instead
  • Change your for-loop to count down from 100 to 0 instead of counting up from 0 to 100
  • Stop here. We'll go over file output together first, then you can continue
  • Simple hello world program here
  • Modified to write to a file instead here
  • Modify this program to print to a file instead.
  • Modify your code by putting your for loop in a separate function, but still have the main function open and close the file