Friday, 1 September 2017

C# tutorial programming | C# program to generate following output

create a simple c# program to generate following output

Program

using System;
class Program
    {
        static void Main(string[] args)
        {
            int i, j;
            for (i = 1; i <= 5; i++)
            {
                for (j = 1; j <= i; j++)
                { 
                    if (j % 2 == 0)
                    {
                        Console.Write("0");
                    }
                     else
                    {
                        Console.Write("1");
                    }
                }
                Console.WriteLine();
            }
        }

     } 

Output


0 comments:

Post a Comment