Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I use C++ compiler Your task is to draw a rectangle of a size (number of rows and columns) specified by the user. The rectangle
I use C++ compiler
Your task is to draw a rectangle of a size (number of rows and columns) specified by the user. The rectangle should have a "special" character (specified by the user) at the corners of the rectangle, inset by one row and column from the edges. Example run (user input in bold): Number of rows: 12 Number of columns: 35 Special character: 0 40- -8 Hints Suggested approach: (1) First, write the code to prompt the user for the number of rows and columns and the "special" character You can read a single non-whitespace character into a variable as follows: char special; scanf(" c", &special); Note: there is a single space character preceeding the %c in the scanf format string. (2) Add code to print a "solid" rectangle of the given size. L.e., don't worry about printing the "special" character at the comers. You should use a pair of nested loops. The outer loop is responsible for generating all of the rows of output making up the rectangle. The inner loop is responsible for printing a single row of the rectangle by repeatedly printing a period("." character The program will need to print a newline (n) character at the end of each row (3) Change the code that prints the period character so that it is an if/else statement of the following form: The idea is that a condition (should be a special character) determines when the special character should be printed. You wil need to think about how to specify this condition. The code above assumes that the char variable called special stores the special character entered by the userStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started