Rectangle Learn programming C#

Lesson:

First contact with C# Sharp


Exercise:

Rectangle


Objetive:

Write a C# program to ask the user for a number and then display a rectangle 3 columns wide and 5 rows tall using that digit. For example:

Enter a digit: 3
333
3 3
3 3
3 3
333


Code:

using System;
public class exercise13
{
    public static void Main()
    {
        int x;
        Console.Write("Enter a number: ");
        x = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("{0}{0}{0}", x);
        Console.WriteLine("{0} {0}", x);
        Console.WriteLine("{0} {0}", x);
        Console.WriteLine("{0} {0}", x);
        Console.WriteLine("{0}{0}{0}", x);
    }
}

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