Q:

Java program to print the following pattern on the console

belongs to collection: Java Pattern programs

0

In this program, we are creating a right-angled triangle of numbers in increasing order. We are creating two loops, and 2nd loop is executing according to the first loop, inside 2nd loop printing the number row-wise i loop times.

1
2 3
4 5 6
7 8 9 10

Algorithm:

  • STEP 1: START
  • STEP 2: SET n=1.
  • STEP 3: SET i=0.REPEAT STEP 4 to STEP 8 UNTIL i<6.
  • STEP 4: SET j=1.REPEAT STEP 5 and 6 STEP UNTIL j<i.< li=""></i.<>
  • STEP 5: PRINT n
  • STEP 6: SET n=n+1, j=j+1.
  • STEP 7: PRINT new line.
  • STEP 8: SET i=i+1.
  • STEP 9: END

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

class pattern     
    
   public static void main(String[] args)     
   {    
       int i ,j;    
       int n = 6;    
           for(i = n; i>0 ; i-- )    
           {    
                for(j = 0; j<i ; j++)    
                   {    
                       System.out.print("*");    
                   }    
                        System.out.println("");    
           }        
   }     

 

Output:

1
2 3
4 5 6
7 8 9 10

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java program to print the following pattern on the... >>
<< Java program to print the following pattern on the...