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
As text is typed in the _____ text box, a drop-down list displays options for completing the action, displaying information on t
pickupchik [31]

Answer:

Excel Help

Explanation:

Press F1 key to open the excel help window

Or you can also click the excel help button to launch the help window.

Type for whatever you are seeking help for and you will notice suggestions as you type something. These suggestions include online and offline results. If there are too many results then try searching offline it will narrow down the results.

After typing the text and hitting enter, the excel help returns several related topics on the searched query. You can browse through these topics and get help from excel.

5 0
3 years ago
How many functions can Excel perform?
Vlad [161]

Answer:

G

Explanation:

because

3 0
4 years ago
Which of the following is a productivity strategy for collaboration?
AfilCa [17]

Answer:

Where are the answer choices? Can you put them down so I can answer them?

Explanation:

8 0
3 years ago
Help please!, explain what is missing and what needs to be changed if anything.
german

Using the computer language in JAVA to write a function code that output numbers in reverse

<h3>Writting the code in JAVA:</h3>

<em>import java.util.Scanner;</em>

<em>public class LabProgram {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner scnr = new Scanner(System.in);</em>

<em>        int[] userList = new int[20];</em>

<em>        int numElements;</em>

<em>        numElements = scnr.nextInt();</em>

<em>        for (int i = 0; i < numElements; ++i) {</em>

<em>            userList[i] = scnr.nextInt();</em>

<em>        }</em>

<em>        for (int i = numElements - 1; i >= 0; --i) {</em>

<em>            System.out.print(userList[i] + " ");</em>

<em>        }</em>

<em>        System.out.println();</em>

<em>    }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

8 0
2 years ago
What is the difference between software and operating system software?
Basile [38]

Answer:

System software is the software that manages the resources and allows a user to interact with the system. On the other hand, an operating system collects programs that coordinate all activities among computer hardware devices.

4 0
3 years ago
Other questions:
  • WILL GIVE BRAINLIEST! An ________________ is a list of steps needed to answer a problem or finish a task. When the code is execu
    14·2 answers
  • What do you click on to minimize all open windows? the Show Desktop icon the Start menu the system tray the taskbar
    15·2 answers
  • Which column and row references are updated when you copy the formula: =SUM($B5:D$15)?
    6·2 answers
  • Which view in file explorer can use to sort files by column heading
    8·1 answer
  • Write a program that will read in a line of text and output the number of words in the line and the number of occurrences of eac
    11·1 answer
  • What lever has resistance between the axis (fulcrum) and the force (effort)?
    10·2 answers
  • When registering online for your classes you log onto to a website provided by your university. The computer and web browser tha
    6·2 answers
  • Kelly arrives for work at a restaurant at 5:00 p.m. Once there, she washes and chops vegetables, then sets aside ingredients and
    8·2 answers
  • If you need any answer answered faster check out Wolframalpha.com
    14·2 answers
  • Which of the following will Excel recognize as a date?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!