Introduction
Hi guys, today I will post how to write a basic star
programming in C#, this is generally helpful to the fresher and whoever
preparing for interviews.
My previous post was Star Programming 5
static void Main(string[] args)
{
Console.WriteLine("Please Enter a number");
int num = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < num; i++)
{
for (int j = 0; j < i; j++)
{
if ((i + j) % 2 == 0)
Console.Write("0");
else
Console.Write("1");
}
Console.WriteLine();
}
}
|
No comments:
Post a Comment