Computer Science, asked by naazpreet13, 2 months ago

WAP to print the pattern
1
1 2
1 2 3
1 2 3 4​

Answers

Answered by BrainlyProgrammer
4

Answer:

//Assuming it is Java programming

class Abc{

public static void main (String ar[]){

for(int I=1;I<=4;I++){

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

System.out.println(j+" ");

System.out.println();

}

}

}

Logic:-

  • Run I loop from 1 to 4
  • Run j loop from 1 to I
  • print j loop
  • close j loop
  • Use System.out.println() to bring the cursor to next line
  • Close I loop
  • close the main () and the class
Similar questions