Can anybody help me to create following program in c#
* * * * *
* *
* *
* *
* * * * *
Print Rectangle of stars in c#
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Feb 18, 2015, 1:16 AM EST
Following are the program just input 5 5 it
will print the output as you want.
using System;
namespace DotNetMirror
{
class PrintRectangleStars
{
static void Main()
{
Console.WriteLine("Program to Print Rectangle *'s");
int width = 0, height = 0;
Console.Write("Enter Height :");
height = int.Parse(Console.ReadLine());
Console.Write("Enter Width :");
width = int.Parse(Console.ReadLine());
for (int i = 1; i <= height; i++)
{
for (int j = 1; j <= width; j++)
{
if ((i == 1 || i == height) || (j == 1 || j == width))
Console.Write("*"); //prints at border place
else
Console.Write(" "); //prints inside other than border
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}