HOW TO DO E PATTERN IN JAVA

E PATTERN IN JAVA

 

The steps of doing E pattern 

1: take input from user for the pattern length

2:take i and j for loop

3:start the loop from 0

4:check if(i|%3==0||j==0) the print ("*) 

else print(" ")

5.close the j for loop and print a new line under the i loop

6.save and run

THE SOURCE CODE

import java.util.Scanner;
class E
{
    public static void main(String[] args)

 {
        Scanner s=new Scanner(System.in);
        int n,i,j;//n is for the number which will user input and i ,j is for loop
        System.out.println("enter the number");
        n=s.nextInt();
        for (i=0;i<n ;i++ )
        {
            for(j=0;j<n;j++)
            {
                if(i%3==0||j==0)
                {
                    System.out.print("*");
                }
                else
                {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }

    }

}

OUTPUT

WATCH MY YOUTUBE VIDEO


Comments

Popular Posts