Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please 2. Figures. Create a project titled Lab3_Figures with a single file figures.cpp. Your program should ask the user for a number and then

C++ pleaseimage text in transcribed

2. Figures. Create a project titled Lab3_Figures with a single file figures.cpp. Your program should ask the user for a number and then print two squares, two diagonal lines and a cross out of stars as shown below. The figure size should be input by the user. Here is an example dialog Input number: 4 Note that your program has to work for an arbitrary integer, not just 4. 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. For the second figure, the star is printed in the column that is equal to the row. 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 row o column 0 column 1 column 2 column 3 02 03 13 102 32 20 30 row 3 In the second figure (the first diagonal line), you print a star when the row index is equal to the column index In the third figure, you print a star when the column index is the same as the maximum number of rows minus the column index The code for the cross is the combination of the code for the two diagona ines 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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