Q:

Java program to print the following pattern on the console

belongs to collection: Java Pattern programs

0

To accomplish this task, we need to create two loops and the 2nd loop is to be executed according to the first loop. The first loop is responsible for printing the line breaks whereas the second loop is responsible for printing the stars (*).

Algorithm:

  • STEP 1: START
  • STEP 2: DEFINE i,j
  • STEP 3: SET n=7
  • STEP 4: PRINT "Right Angle Triangle"
  • STEP 5: SET i=1.REPEAT STEP 6 to 8 UNTIL i<n< li=""></n<>
  • STEP 6: SET j = 1 .REPEAT STEP 7 UNTIL j<=i
  • STEP 7: PRINT * and SET j=j+1
  • STEP 8: PRINT new line and 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, n=7;  
   System.out.println("Right angle triangle");  
   for(i=1;i<n;i++)  
   {  
   for(j=1;j<=i;j++)  
   {  
       System.out.print(" *");  
   }  
       System.out.println("");  
   }  
   }  

Output:

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...