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

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question

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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,