Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a lab on this assignment. I'm very lost on it and I could use help. 2. Figures. Create a project titled Lab3_Figures with

I have a lab on this assignment. I'm very lost on it and I could use help.

image text in transcribedimage text in transcribed

2. Figures. Create a project titled Lab3_Figures with a single file figures.cpp. Your program should ask the user for figure size and then print the figures as shown below. Here is an example dialog: Input number: 7 ********* Note that your program has to work for an arbitrary integer, not just 7. You can use either while or for looping constructs. Hints: For each figure, you need to use two nested loops: the outer loop will iterate over rows (of stars) and the inner loop will print out the stars in a single row. The programming structure for all figures is similar. Study the code for the odometer program. This program has nested loops which are very similar to what you need to implement. I suggest you code and debug the first figure printout and then proceed to the next. The figure order is in the increasing difficulty. In the second figure (the first diagonal line), you print a star when the row index is equal to the column index. That is, the loop variable of the outer loop should be present in the loop-expression of the inner loop. Consider the numbers of row and columns in a table. These numbers will be reflected by the loop variables: column index is red row index is green column 0 column 1 column 2 column 3 column 4 row 00 01 02 03 04 row 1 10 11 12 13 14 20 21 22 23 24 row 3 30 31 32 33 34 40 41 42 43 44 row 2 row 4. In the third figure, you print a star when the column index is the same as the figure size minus the row index minus one. To put another way: row plus column equals figure size minus one. To code the hollow square, consider using a multiway if with the following logic: If it is the first line - then print a star else if it is the last line - then print a star else if it is the first column - then print a star else if it is the last column - then print a star else print a space The diamond is the combination of diagonal lines

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

=+ a. A change in consumer preferences increases the saving rate.

Answered: 1 week ago