Question: In C program #include This program with use functions to print simple shapes: Lines Triangles Rectangles using *'s. Write a program with 3 functions defined
In C program
#include
This program with use functions to print simple shapes:
- Lines
- Triangles
- Rectangles
using *'s.
Write a program with 3 functions defined as follows:
- void printLine (int length)
- void printTriangle (int baseWidth)
- void printRectangle (int width, int height);
The main program should prompt the user for a shape:
- l or L for a line
- then prompt for an integer length (range 1-25)
- if the length is valid, call the printLine function
- t or T for a triangle
- then prompt for an integer width for the base (range 3-25)
- if the length is valid, call the printTriangle function
- r or R for a rectangle
- then prompt for an integer width and height (range 2-25)
- if the length & width are valid, call the printRectangle function
The length and width must be in the ranges specified for the shape above (you must verify that the input is correct).
Any other letter should generate an error message.
Start your implementation with the printLine function.
Once that function works, use printLine to implement printRectangle and printTriangle (ie call your printLine function appropriately).
HINT: it may be easier to get printRectangle working before printTriangle. DO NOT modify the function prototypes in the starter file.
For Example:
Which shape (L-line, T-triangle, R-rectangle): L Enter an integer length between 1 and 25: 13 *************
Which shape (L-line, T-triangle, R-rectangle): t Enter an integer base length between 3 and 25: 5 * ** *** **** *****
Which shape (L-line, T-triangle, R-rectangle): r Enter an integer width and height between 2 and 25: 4 5 **** **** **** **** ****
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
