Computer Science, asked by parasgoyal0201, 1 year ago

Print the following pattern using JAVA

*
*#
*#*
*#*#

Answers

Answered by QuantumDude
0

public class pattern

{

public static void main (String args[])

{

System.out.println("*");

System.out.println("*#");

System.out.println("*#*");

System.out.println("*#*#");

}

}

Here ends your program. I hope it helps!!!!!

Answered by anindyaadhikari13
1

Question:-

Write a program in Java to print the following pattern.

*

*#

*#*

*#*#

Program:-

Here is your program in Java.

import java.util.*;

class Pattern

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number of rows for the pattern: ");

int n=sc.nextInt();

for(int i=1;i<=n;i++)

{

for(int j=1;j<=i;j++)

{

if(j%2==1)

System.out.print("* ");

else

System.out.print("# ");

}

System.out.println();

}

}

}

Similar questions