Computer Science, asked by kamthanneeraj, 1 year ago

4
34
234
1234
Pattern question
Java program using for loop

Answers

Answered by utkarshmishra9819
8

Answer:

class prog

{

void main()

{

for(int i=4;i>=1;i--)

{

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

{

System.out.print(j);}

System.out.println();

}

}

Answered by ridhimakh1219
3

Java program to print numbered pattern

Explanation:

Java Program

import java.util.Scanner;

public class Main

{

   public static void main(String[] args)

   {

       // Create a new Scanner object

       Scanner sc = new Scanner(System.in);

       // Input no. of rows

       System.out.println("Enter the number of rows ");

       int rows = sc.nextInt();

       System.out.println("---Print the pattern---");

       for (int i = rows; i >= 1; i--)

       {

           for (int k = i; k <= rows; k++)

           {

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

           }

           System.out.println();

       }

   }

}

Output

Enter the number of rows                                                              

4                                                                                                     

---Print the pattern---                                                                      

4

34

234

1234

Similar questions