Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

User Lab 3 - Fancy shapes In this lab we'll be focusing on the C programming aspect. This will cover for - loops and if

User
Lab 3- Fancy shapes
In this lab we'll be focusing on the C programming aspect. This will cover for-loops
and if-statements. To practice these we'll be drawing some shapes in the terminal!
The input will be one of the following numbers, passed through argv:
1. A square
2. A triangle
3. An inverted triangle (upside down)
4. A diamond
Your program will take in 2 arguments. The first is a number between 1 and 4,
indicating which of the shapes listed above you'll be printing. The second argument is
a number indicating the largest horizontal width of the shape. For example, for a
triangle, this'll be the width of the base.
Your program will print the indicated shape at the indicated dimensions. Write your
code in the main.c file provided in the starter repository.
Examples
Example 1
./a.out 14
Output:
$$$$
$$$$
$$$$
$$$$
Example 2
./a.out 110
Output:
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$
Example 3
./a.out 26
Output:
$$
$$$$
$$$$$$
Notice how with an even number for the width, will result with 2 at the top, not one.
Example 4
./a.out 27
Output:
$
$$$
$$$$$
$$$$$$$
$$$$$$$$$
Example 5
./a.out 314
Output:
$$$$$$$$$$$$$$
$$$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$
$$$$$$
$$$$
$$
Example 6
./a.out 414
Output:
$$
$$$$
$$$$$$
$$$$$$$$
$$$$$$$$$$
$$$$$$$$$$$$
$$$$$$$$$$$$$$
$$$$$$$$$$$$
$$$$$$$$$$
$$$$$$$$
$$$$$$
$$$$
$$
Example 7
./a.out 415
Output:
$
$$$
$$$$$
$$$$$$$
$$$$$$$$$
$$$$$$$$$$$
$$$$$$$$$$$$$
$$$$$$$$$$$$$$$
$$$$$$$$$$$$$
$$$$$$$$$$$
$$$$$$$$$
$$$$$$$
$$$$$
$$$
$

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

More Books

Students also viewed these Databases questions

Question

Explain how cultural differences affect business communication.

Answered: 1 week ago

Question

List and explain the goals of business communication.

Answered: 1 week ago