I want to create a program that outputs 4 squares that looks like the Windows logo. So far I’ve managed to create 2 squares that look like this:
[ ]
[ ]
I’ve made 2 vertical squares first. So how do you add the other 2 vertical squares to complete the Windows logo?
[ ] [ ]
[ ] [ ]
Here’s my code:
Console.BackgroundColor = ConsoleColor.DarkCyan;
Console.Clear();
int size = 10;
Console.WriteLine();
for (int row = 3; row <= size; row++)
{
for (int col = 0; col <= size + 1; col++)
{
if (col == 0)
{
Console.BackgroundColor = ConsoleColor.DarkCyan;
Console.Write(" ");
Console.ResetColor();
}
else
{
Console.BackgroundColor = ConsoleColor.White;
Console.Write(" ");
Console.ResetColor();
}
}
Console.WriteLine();
}
Console.WriteLine();
for (int row = 3; row <= size; row++)
{
for (int col = 0; col <= size + 1; col++)
{
if (col == 0)
{
Console.BackgroundColor = ConsoleColor.DarkCyan;
Console.Write(" ");
Console.ResetColor();
}
else
{
Console.BackgroundColor = ConsoleColor.White;
Console.Write(" ");
Console.ResetColor();
}
}
Console.WriteLine();
}
Console.ReadKey();
Here is your code (on which you should work a lot) changed so it should draw what you want. I would suggest refactor it a little bit. Note that you should increase the size to at least double and to write once DarkCyan after you draw the first rectangle (at the middle of the size). Check the code: