Computer Science, asked by suhanitriesyo, 9 months ago

Write a program in Java to print this pattern:
@
@#@
@#@#
@#@#@

Answers

Answered by mishthi28
0

Answer:

for(x=1;x<=5;x++)

{

for(y=1;x<=x;y++)

{

if(y%2==0)

System.out.print("#");

else

System.out.print("@");

}

System.out.println( );

}

Answered by anindyaadhikari13
2

Question:-

Write a program in Java to print the following pattern.

Program:-

Here is the shortest program.

class Pattern

{

public static void main(String args[])

{

char ch='@';

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

{

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

{

System.out.print(ch+" ");

ch=(ch=='@')?'#':'@';

}

System.out.println();

}

}// end of main()

}// end of class.

Similar questions