Wednesday, 26 January 2022

A) Write a java Program to display following pattern:

Slip 9 Q 1

Save code as         "Pattern1.java"


            

            0 1 

            0 1 0 

            1 0 1 0



public class Pattern1 {
    public static void main(String[] args) {
        int num = 4;
        for (int i=0;i<num;i++){
            for(int j=0;j<=i;j++){
                if (i<2){
                    if ((i+j)%2==0){
                        System.out.print("1 ");
                    }else{
                        System.out.print("0 ");
                    }
                }else{
                    if ((i+j)%2==0){
                        System.out.print("0 ");
                    }else{
                        System.out.print("1 ");
                    }
                }
            }System.out.println();
        }
    }
}



OUTPUT:




2 comments:

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...