Thursday 28 July 2016

Star Programming 1

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. Slowly I will post more Star Programming related articles.

*
**
***
****
*****
******
*******
********

static void Main(string[] args)
{
    Console.WriteLine("Enter a number");
    int num = Convert.ToInt32(Console.ReadLine());
    for (int i = 0; i < num; i++)
    {
       for (int j = 0; j <= i; j++)
       {
           Console.Write("*");
       }
       Console.WriteLine();
    }
}

No comments:

Post a Comment