Question: Use for loops (hint: nested) to generate the patterns. All asterisks should be displayed by a single statement of the form Console.Write(*); which displays the

Use for loops(hint: nested) to generate the patterns. All asterisks should be displayed by a single statement of the form Console.Write("*"); which displays the asterisks leading up to the number value shown in the example. A statement of the form Console.WriteLine(); can be used to move to the next line. Note the sequence of each number in turn. Remember that this is two separate sets of loops which are used to generate these two patterns. You will need to deduce how the numbers are computed (they are the result of a computation) and where that computation will be placed in the loop structures. You may not hardcode the displayed numbers into your loops.

The two patterns should look similar to the following:

*2 **4 ***6 ****8 *****10 ******12 *******14 ********16 *********18 **********20 **********20 *********18 ********16 *******14 ******12 *****10 ****8 ***6 **4 *2 Press any key to continue . . .

My broken code

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace Assignment_3 { class Program { const char star = '*'; const char space = ' '; const int count = 10; static void Main(string[] args) { Display1(); Display2(); Console.ReadLine(); } static public void Display1() { int number = 2; for (int r = 0; r < count; r++) { for (int c = 0; c <= r; c++) { Console.Write(star); Console.Write(number + 2); }

}

} static public void Display2() { int number = 20; for (int r = 0; r < count; r++) { for (int c = 0; c < r; c++) Console.Write(space);

for (int c = 0; c < count - r; c++) Console.Write(star); Console.Write(number - 2);

} } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!