Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.1 Drawing a Rectangle (Provided as Reference) The first function is to draw a rectangle of a specific size. Given the number of rows and

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
4.1 Drawing a Rectangle (Provided as Reference) The first function is to draw a rectangle of a specific size. Given the number of rows and columns, this function will draw the rectangle using print f() function and asterisks (). The function has been already defined in draw. h and draw. c. draw. h is a header file. Other C programs can include this header file and access the functions defined in draw. c. You don't need to change anything in this header file. In draw. h, you can see a line: void drawRectangle (int rows, int columns); This is the function signature of the function drawRectangle (). The function takes two arguments: rows and columns for the rectangle - both are of int type. It will draw a rectangle of the certain size defined by rows and columns using print f() and asterisks. It does not return any value as indicated by void. In draw. c, you can see the actual function (and, of course, the content of that function is empty and for you to fill). The function has been implemented and provided to you as a reference. Think about how to adapt this function for the following two parts. Read the comments in draw. c to see the expected output for this function. 4.2 Drawing a Triangle (40\% grade) The second function drawTriangle () is to draw a triangle of a specific size. You should be able to draw the triangle using print f() function, asterisks (), and plus signs ( +). The function has been already defined in draw.h and draw. c. Similar to the previous part, implement the drawTriangle() function in draw. c. Do not edit anything in draw.h. Read the comments in draw. c to see the expected output for this function. 4.3 Drawing a Right Trapezoid (40\% grade) The third function drawRight Trapezoid () is to draw a right trapezoid of a certain size. You should be able to draw the right trapezoid using print f() function, asterisks (), and plus signs ( +). The function has been already defined in draw.h and draw. c. Similar to previous parts, implement the drawRightTrapezoid () function in draw. c. Do not edit anything in draw. h. Read the comments in draw. c to see the expected output for this function. Clarification: For the function drawRightTrapezoid(top, bottom), the comment says "A function to draw a right trapezoid using asterisks (*) and plus signs ( +) with given number of rows." This may have caused some confusion. It should be "A function to draw a right trapezoid using asterisks () and plus signs ( +, with the top row having top characters and the bottom row having bottom characters." For example: If top=2 and bottom =5, you should have a right trapezoid with 4 rows, each row having 2 , 3,4 , and 5 characters (made of * and + ). 4.4 Putting Everything Together (20\% grade) Now as you have implemented drawTriangle () and drawRight Trapezoid (), it's time to put them together. In the start.c you can see the main () function. We have left numerous amount of comments in start. c to explain some basic aspects of C. The program will take 3 arguments. The first argument is the number of rows for the triangle. The next two arguments are the numbers of symbols in the top and bottom rows for the trapezoid. Suppose the compiled executable file is located at ./start, then running ./start 457 is to draw a triangle of 4 rows with asterisks and plus signs, and then draw a right trapezoid with three rows, with 5,6 , and 7 symbols with asterisks and plus signs, respectively. To achieve this, you need to add two lines in start.c - one for each function you've written in the previous two parts. We have provided an example of calling a function in the code, which will call drawRectangle () with given arguments. Do not edit this line. Add the function calls of drawTriangle and drawRight Trapezoid() after this line at given location. We've handled the arguments and stored them as variables for you, so you can use those variables directly. What you need to do is to call drawTriangle () with the respective argument to draw the triangle, then call drawRightTrapezoid() to draw the right trapezoid also with the respective arguments. Once again, please read through the comments in start. c and see where you should put these two lines at

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

Students also viewed these Databases questions

Question

4. Are there any disadvantages?

Answered: 1 week ago

Question

3. What are the main benefits of using more information technology?

Answered: 1 week ago

Question

start to review and develop your employability skills

Answered: 1 week ago