Colour Theme Font Size Options
 
 
 
Exercise 3

Nested While Loops Exercise

Create a C++ program ex3_linect.cpp with the following code in the Visual Studio project or copy the following code into your IDE:


This program will use a pair of nested while loops to count how many characters appear on each line of a file. The outer loop will count the lines of the file, the inner loop will count the characters on the current line.

Instructions:

  • Complete ex3_linect.cpp according to the "Add code: " comments in the program.
  • This program uses file I/O so you need an input file. To create one, make a copy of the source file.
  • Compile and run this C++ program.

When you are done:

  • Take a screenshot of your IDE and console window after compiling and running the program.
  • For this exercise, you will have: ex3_linect.cpp and an input file called LineData.txt.