Computer Science, asked by NinjaBhaskar, 1 year ago

Write a C++ program to print the following pattern

Attachments:

Answers

Answered by namansanjay0p3sg0a
1
import java.util.Scanner; class MainClass
{
public static void main()     
{
Scanner sc = new Scanner(System.in);                 
System.out.println("How many rows you want in this pattern?");                 
int rows = sc.nextInt();                 
System.out.println(" pattern....!!!");                 
for (int i = 1; i <= rows; i++)        
{
 for (int j = 1; j <= i; j++)           
 { if(j%2=0)                

 System.out.print(0);               
 }               
 else                
{
System.out.print(1);               
 }           
 }                         
System.out.println();        
}                 
sc.close();    
}
}
Similar questions