Question: Write a C + + program that uses a nested loop to print a box based on character and dimension provided by the user. You
Write a C program that uses a nested loop to print a box based on character
and dimension provided by the user.
You should have a function to read the character to use, so its prototype can be
something like this.
char readChar;
Another function to read the value for the row and also for the columns. That is
you will use the same function to read both these two different values. Its
prototype can be something like this:
int getNumstring;
You will pass different values for the string argument to indicate which one you
are trying to get. For example, you can use statement below to read value for
rows.
rows getNumHow many rows? ;
Similarly, to get the value for the columns into the variable cols, we will call the
same getNum function but now with a different string. So it will be:
cols getNumHow many columns? ;
Remember to validate the value entered in the getNum function such that only
positive values are accepted.
Lastly a function to print the box, and the function header can be something like
this:
void printBoxint rows,int cols,char ch;
A sample run is as follows.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
