Q:

C# program to print pattern of 0\'s and 1\'s

0

C# program to print pattern of 0's and 1's

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

using System;  //include the namespace
namespace program
{
	class ab
	{
		static void Main(String[] args)
		{
			int i,j,c=0;
			
			for(i=0;i<4;i++)  //loop for row
			{
				for(j=0;j<=i;j++)  //loop for column
				{
					c++;  //increment in count variable
					if(c%2==0)  
						Console.Write(0);
					else
						Console.Write(1);
				}
				Console.WriteLine();  //for new line
			}
		}
	}
}

Output

1
01
010
1010

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now