Computer Science, asked by sdassamanta1, 11 months ago

please answer this Java program fast .it is a pattern​

Attachments:

Answers

Answered by ArbazTahir
1

Explanation:

I'm Giving just the for loop code

int a=1

for( int i=1;i<=5;i++)

{

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

{

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

a++;

}

System.out.print();

}

Just Use this forloop code along with class name and functions....etc

Get ur Pattern Displayed

Hope This Helps you

Answered by anindyaadhikari13
1

Question:-

Write a program in Java to display the following pattern.

1

2 3

4 5 6

7 8 9 10

Program:-

import java.util.*;

class Pattern

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

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

int n=sc.nextInt();

int a=1;

for(int i=1;i<=n;i++)

{

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

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

System.out.println();

}

}

}

Similar questions