Computer Science, asked by mumaid018, 2 months ago

Write a program in Java to display the following pattern
1
2 3
4 5 6
7 8 9 10​

Answers

Answered by anindyaadhikari13
4

\texttt{\textsf{\large{\underline{The C{o}de!}}}}

Note: Here, I have assumed that the number of rows is fixed.

public class Pattern{

   public static void main(String args[]){

       for(int i=1,a=1;i<=4;i++){

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

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

           System.out.println();

       }

   }

}

\texttt{\textsf{\large{\underline{O{u}tput!}}}}

1  

2 3  

4 5 6  

7 8 9 10

See attachment for verification.

Attachments:
Answered by kamalrajatjoshi94
0

Answer:

Program:-

public class Main

{

public static void main(String args[])

{

int i,j,p=1;

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

{

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

{

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

p++;

}

System.out.println();

}

}

}

Attachments:
Similar questions