Q:

Java program to print the following pattern on the console

belongs to collection: Java Pattern programs

0

Algorithm:

  • STEP 1: START
  • STEP 2: SET i =1.REPEAT STEP 3 to 7UNTIL i<=10.
  • STEP 3: SET j=1.REPEAT STEP 4 and 5UNTIL j<=10.
  • STEP 4: if(i==0 or i==10 or j==0 or j==10) then PRINT 1 else PRINT ""
  • STEP 5: SET j=j+1
  • STEP 6: PRINT new line.
  • STEP 7: SET i=i+1
  • STEP 8: END

All Answers

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

Program:

public class pattern  
{  
    public static void main(String[] args) {  
        for (int i = 1; i <= 10; i++)  
    {  
        for (int j = 1; j <= 10; j++)  
        {  
            if (i==1 || i==10 || j==1 || j==10 )  
                System.out.print(" 1");  
            else  
                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...