Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions