modules in C++ (void functions) to display the two specified patterns when calling them from main. Set up main and the two void functions. Run the program with the four calls below and confirm the output. Submit both source code and output. // calls from main rectanglePattern(3, 4); // 3 by 4 rectangle of # characters rectanglePattern(2, 5); // 2 by 5 re
Complete the two modules in C++ (void functions) to display the two specified patterns when calling them from main. Set up main and the two void functions. Run the program with the four calls below and confirm the output. Submit both source code and output.
// calls from main
rectanglePattern(3, 4); // 3 by 4 rectangle of # characters
rectanglePattern(2, 5); // 2 by 5 rectangle of # characters
trianglePattern(3, ‘*’);
trianglePattern(4, ‘#’);
Sample output:
Author: [Your name]
####
####
####
#####
#####
*
**
***
#
##
###
####
You must use a nested loop and output one ‘#’ at a time inside the inner loop. Each line has up to rows ‘#’ characters (inner loop) and there are rows of lines of characters (outer loop).
void rectanglePattern(int rows, int cols)
// set up a nested loop using rows and cols
// use cout << ‘#’; inside the nested loop
You must use a nested loop and output one character at a time inside the inner loop. The first line has one character and the nth row has n characters.
void trianglePattern(int rows, char c)
// set up a nested loop using row and outer loop counter
// use cout << c; inside the nested loop
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images