w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: Display a number in rectangle of 3 columns wide and 5 rows tall using that digit


C# Sharp Basic: Exercise-13 with Solution

Write a C# program that takes a number as input and then displays a rectangle of 3 columns wide and 5 rows tall using that digit.

C# Sharp Exercises: Display a number in rectangle of 3 columns wide and 5 rows tall using that digit

Sample Solution:

C# Sharp 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);
    }
}

Sample Output:

Enter a number: 5                                                                                             
555  
5 5 
5 5
5 5 
555

Flowchart:

Flowchart: C# Sharp Exercises - Display a number in rectangle of 3 columns wide and 5 rows tall using that digit

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# program to that takes a number as input and display it four times in a row (separated by blank spaces), and then four times in the next row, with no separation. You should do it two times: Use Console. Write and then use {0}
Next: Write a C# Sharp program to convert from celsius degrees to Kelvin and Fahrenheit.
kelvin = celsius + 273

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming