Question: Exercise 4: Rewrite your C++ solution to Exercise 3 so that the symbol used as the border is also read as data and passed to

Exercise 4: Rewrite your C++ solution to Exercise 3 so that the symbol used as the border is also read as data and passed to function Print as a parameter. To make the symbol be a parameter requires the following changes:

Prompt for and read the symbol.

Add the symbol and its type (or just the type) to the parameter list of the function prototype.

Add the symbol and its type to the parameter list of the function definition. Use the parameter instead of $ in the body of the function definition.

Add the symbol to the argument list. Run the program three times using &, %, and A as symbols and 4, 10, and 7 as the number of symbols to use.

This is what I have so far:

#include #include #include using namespace std; void print(int numSigns); int main () { int numSigns; cout<<"Enter the number of dollar signs for the top;"; cout<<"press return."; cout<<"Enter a negative number to quit."<>numSigns;

while(numSigns>=0) { print(numSigns); cout<<"Enter the number of dollar signs for the top;"; cout<<"press return."; cout<<"Enter a negative number to quit."<>numSigns; } return 0; } void print(int numSigns) { int width,height; width=numSigns/2; height=numSigns; //Displaying the output for(int i=1;i<=width;i++) { for(int j=1;j<=height;j++) { if( (i==1 || i==width) || (j==1 || j==height)) cout<<"$"; else cout<<" "; } cout<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!