Rectangle V2 Learn programming C#

Lesson:

Flow Control


Exercise:

Rectangle V2


Objetive:

Write a C# program that asks for a number, width, and height, and displays a rectangle of that width and height, using that number for the inner symbol, as shown in the example below:

Enter a number: 4
Enter the desired width: 3
Enter the desired height: 5

444
444
444
444
444


Code:

using System;
public class exercises36
{
    public static void Main()
    {
        int n;
        int row, column;

        Console.Write("Enter a number: ");
        n = Convert.ToInt32(Console.ReadLine());

        Console.Write("Enter the desired: ");
        width = Convert.ToInt32(Console.ReadLine());

        Console.Write("Enter the desired height: ");
        height = Convert.ToInt32(Console.ReadLine());

        for (row = 0; row; row++)
        {
            for (column = 0; column; column++)
                Console.Write(n);

            Console.WriteLine();
        }
    }
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.