1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Harman [31]
3 years ago
10

Write a piece of code that constructs a jagged two-dimensional array of integers named jagged with five rows and an increasing n

umber of columns in each row, such that the first row has one column, the second row has two, the third has three, and so on. The array elements should have increasing values in top-to-bottom, left-to-right order (also called row-major order). In other words, the array's contents should be the following: 1 2, 3 4, 5, 6 7, 8, 9, 10 11, 12, 13, 14, 15
PROPER OUTPUT: jagged = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]
INCORRECT CODE:
int jagged[][] = new int[5][];
for(int i=0; i<5; i++){
jagged[i] = new int[i+1]; // creating number of columns based on current value
for(int j=0, k=i+1; j jagged[i][j] = k;
}
}
System.out.println("Jagged Array elements are: ");
for(int i=0; i for(int j=0; j System.out.print(jagged[i][j]+" ");
}
System.out.println();
}
expected output:jagged = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]
current output:
Jagged Array elements are:
1
2 3
3 4 5
....
Computers and Technology
1 answer:
Ksivusya [100]3 years ago
4 0

Answer:

Explanation:

The following code is written in Java and it uses nested for loops to create the array elements and then the same for loops in order to print out the elements in a pyramid-like format as shown in the question. The output of the code can be seen in the attached image below.

class Brainly {

   public static void main(String[] args) {

       int jagged[][] = new int[5][];

       int element = 1;

       for(int i=0; i<5; i++){

           jagged[i] = new int[i+1]; // creating number of columns based on current value

           for(int x = 0; x < jagged[i].length; x++) {

               jagged[i][x] = element;

               element += 1;

           }

       }

       System.out.println("Jagged Array elements are: ");

       for ( int[] x : jagged) {

           for (int y : x) {

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

           }

           System.out.println(' ');

       }

       }

   }

You might be interested in
Information to develop a project network is collected from the.
Kryger [21]

Information to develop a project network is collected from the work breakdown structure

<h3>Work breakdown structure </h3>

Work breakdown structure (WBS)  is a structure showing the steps needed to be taken so as to complete a project.

WBS is presented in visual format and it is usually arranged based on hierarchy.

Information to develop a project network is collected from the work breakdown structure

Find out more on Work breakdown structure at: brainly.com/question/6197566

7 0
2 years ago
12. When computer professionals take on jobs, they may not enter into relationships with which of the
weeeeeb [17]

Answer:

12 is c. 13 is a .14 is c 15 I don't know sorry

6 0
3 years ago
Signe wants to improve the security of the small business where she serves as a security manager. She determines that the busine
jek_recluse [69]

Answer:Obscurity

Explanation: Security through the obscurity is the mechanism that is used for the security purpose in an operating system by inducing the confidentiality in the internal parts of the operating system.

The functioning of the security through obscurity(STO) works by hiding the  flaws and errors related to security  of the operating system.Thus , Signe is willing to use obscurity system.

 

6 0
3 years ago
What is the technological singularity and what are the dangers it brings to man
professor190 [17]
The definition according to google and the dictionary of technological singularity is the following : The technological singularity (also, simply, the singularity) is the hypothesis that the invention of artificial superintelligence will abruptly trigger runaway technological growth, resulting in unfathomable changes to human civilization.

The dangers this brings to man kind is the fact that people will turn out to not be people or there may be a different species considered as humans or human kind .Also we were made as humans from something else artificial super intelligence will basically be forming from us which means it will be forming from something that was already mean basically meaning there will be something changed within the species or artificial super intelligence itself.
3 0
3 years ago
Five advantages of Internet​
Novosadov [1.4K]

Answer:

Information, knowledge, and learning.

Selling and making money.

Banking, bills, and shopping.

Donations and funding

Entertainment.

Explanation:

I hope this helps! ^^

☁️☁️☁️☁️☁️☁️☁️

7 0
2 years ago
Read 2 more answers
Other questions:
  • How could the provisions in the new health reform bill improve access to care?
    14·1 answer
  • Which of the following is a narrative essay most like?
    10·2 answers
  • Help what is a computer made from (computer class question)!!
    9·1 answer
  • I will upvote....
    10·1 answer
  • Describe the difference between a myth and a fable.
    12·1 answer
  • - Which amongst the following is not a Characteristic of Cloud Computing?
    5·1 answer
  • I dont understand this at all! PLZ help me
    14·1 answer
  • Which of the following statements is true regarding a user account? Once a user account has been created, it cannot be completel
    8·1 answer
  • What is another name for a numbered list
    6·1 answer
  • I have a problem. I can't cycle between game packs on my strike pack, I've watched so many vids I'm on Xböx and I'm holding the
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!