This week’s assignments deal with files and nested loops. Input: The program prompts for the name of an input file and the name of an output file. The input file contains two positive (non-zero) integers, m and n, each less than 20, followed by a character. Output: A file containing an m × n rectangle made using the specified character. For example, if the input file contained the numbers 4 and 6 and the character ⋆ as shown below, 4 6* the output file would show 4 lines of 6 stars each, as shown below: ****** ****** ****** ******
This week’s assignments deal with files and nested loops.
Input: The
input file contains two positive (non-zero) integers, m and n, each less than 20, followed by a
character.
Output: A file containing an m × n rectangle made using the specified character.
For example, if the input file contained the numbers 4 and 6 and the character ⋆ as shown below,
4 6*
the output file would show 4 lines of 6 stars each, as shown below:
******
******
******
******
This program will start by opening the input file and reading the numbers and the specified charac-
ter. Thereafter a nested for loop will generate the pattern. The following questions are designed
to step you through the process of creating the nested loop.
Pre-lab component: Question 1: Using Raptor, create a flowchart for the following process:
write a specified character (denoted ch) n times on the output stream and move the cursor to the
beginning of the next line. (In Raptor, the character must be put in double quotes. When writing,
uncheck the “end current line” box to stay on the same line; write an empty string with the box
checked to go to the next line.)
Pre-lab component: Question 2: Created a nested loop in Raptor. The outer loop will run the
inner loop a specified number of times. The result will be rectangular block of characters. Example
for constructing a nested Raptor loop can be found here. Note that when you draw the nested loop
1
in Raptor, the outer loop is created first, and the inner loop is placed inside it.
Question 3: Implement your
CourseInfo/Files/ in CourseFiles for help with opening files.) Create three sample data files. In
a script session, do the following:
1. cat the program file and compile it using g++.
2. For each data file you created, display the file, run the program and display the resulting output
file.
“Since you have asked multiple questions, we will solve the first question for you. If you want any specific question to be solved, then please specify the question number or post only that question.”
The C++ language is developed by Bjarne Stroustrup. The C++ language is used to develop system software. C++ provides different ways of programming such as functional, object-oriented, procedural, and so on.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images