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
frutty [35]
3 years ago
12

The following 2D array has been created:

Computers and Technology
2 answers:
Airida [17]3 years ago
4 0

Answer:

public class Main

{

public static void main(String[] args) {

 

 int [][] a = new int[4][5];

 

 a[0][0] = 1;

 a[0][1] = 2;

 a[0][2] = 3;

 a[0][3] = 4;

 a[0][4] = 5;

 a[1][0] = 10;

 a[1][1] = 9;

 a[1][2] = 8;

 a[1][3] = 7;

 a[1][4] = 6;

 a[2][0] = 11;

 a[2][1] = 12;

 a[2][2] = 13;

 a[2][3] = 14;

 a[2][4] = 15;

 a[3][0] = 20;

 a[3][1] = 19;

 a[3][2] = 18;

 a[3][3] = 17;

 a[3][4] = 16;

 

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

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

         System.out.print(a[i][j] + " ");

     }

     System.out.print("\n");

 }

}

}

Explanation:

  • Inside the main method, initialize the 2D array with their respective values at the appropriate indexes.
  • Iterate over the 2D array using a nested For loop.
  • The outer loop iterates over the rows, while the inner loop iterates over the columns of the 2D array respectively.
  • Finally inside the nested For loop, print the value of 2D array using the i and j index.

Output:

1 2 3 4 5

10 9 8 7 6

11 12 13 14 15

20 19 18 17 16

RSB [31]3 years ago
3 0

Answer:

I wrote this program using C# and Visual Studio. This program requires to display 2D array which has 4 rows and 5 columns. it is also noted that, this program requires to display first and third row in ascending order while second and fourth row in descending order.

To iterate through each row for loop is used and inside for loop, switch statement is used to decide on first, second, third and fourth row that is which rows should be displayed in ascending orders, and which are required to display in descending orders.

Explanation:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace _2D_Array

{

   class Program

   {

       static void Main(string[] args)

       {

           int[,] a = new int[4, 5]{

                              {1, 2, 3,4,5} ,   /*  initializers for row indexed by 0 */

            {6, 7,8,9,10} ,   /*  initializers for row indexed by 1 */

          {11,12,13,14,15},/*  initializers for row indexed by 2 */

                              { 16,17,18,19,20},/*  initializers for row indexed by 3 */

           };

           for (int row = 0; row < 4; row++)// here we iterate through each row and display the result

           {

               switch (row)//the purpose of using switch statement  is that, we will display first and 3rd row in ascending order while 2nd and 5th row in descending order

               {

                   case 0:// here to display row 1

                       {

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

                           {

                               Console.Write("[");

                               for (int j = 0; j < 5; j++)

                                   Console.Write(a[i, j]+ (j >3 ? "" : ","));

                           }

                           Console.Write("]");

                           Console.WriteLine();

                           

                       }

                       break;

                   case 1://here to display row two

                       {

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

                           {

                               //Console.WriteLine("row 1");

                               Console.Write("[");

                               for (int j = 4; j >= 0; j--)// to display array elements in reverse order

                               {

                                   Console.Write(a[i, j] + (j == 0 ? "" : ","));

                               }

                           }

                           Console.Write("]");

                           Console.ReadLine();

                           break;

                       }

                   case 2://here to display the 3rd row

                       {

                           for (int i = 2; i < 3; i++)

                           {

                               Console.Write("[");

                               for (int j = 0; j <5; j++)

                               {

                                   Console.Write(a[i, j] + (j > 3 ? "" : ","));

                               }

                           }

                           Console.Write("]");

                           Console.ReadLine();  

                       }

                       break;

                   case 3://here to display 4th row.  

                       {

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

                           {

                               //Console.WriteLine("row 1");

                               Console.Write("[");

                               for (int j = 4; j >= 0; j--)

                               {

                                   Console.Write(a[i, j] + (j == 0 ? "" : ","));

                               }

                               Console.Write("]");

                           }

                           Console.ReadLine();

                       }

                       break;

               }

           }

       }

   }

}

You might be interested in
(If the link is not working, search for "Veritasium Levitating Barbecue". At approximately the 2 minute mark, the screen shows 8
11111nata11111 [884]

Answer:

Check the explanation

Explanation:

800A stands for a current of 800 Ampes and 900Hz stand for the frequency (the change in the electric field with time) of 900 Hz. In this video footage they’re trying to raise the 1 kg plate, and the major factor that is in charge in lifting the plate is the magnet field that is present. So the whole purpose of this experiment is attempting to produce a big enough magnetic force in order to lift the plate.

From the equation, we are aware that the bigger the current (800A) the bigger the magnetic force. Also, the bigger the frequency, the bigger the change in the electric field. therefore producing a bigger magnetic field and force. these figures have to be really large or larger enough to produce a powerful magnetic force strong enough to lift the plate.

4 0
3 years ago
Firewalls are categorized into two; namely hardware firewall and software firewall. Identify the correct statement for a softwar
garri49 [273]

Answer:

Option (d) Software firewall is placed between the normal application and the networking components of the operating system

Explanation:

  • Software Firewalls protect the computer from trojans and malicious content which can arise from unsafe applications.
  • It also protect the computer from external network.
  • It filters the data to and from a software application in the desktop.
  • It also filters the data to and from a network.
  • It safeguards the computer from not loosing access to the attackers.
  • It is customizable software and has to be monitored like installing updates and storage spaces etc.
  • Software Firewall in conjunction with the Hardware Firewall must be used for the security of the desktop and the networks.
5 0
3 years ago
Excel makes reading formulas simpler by ____ each cell reference in the formula and its corresponding cell in the worksheet.
Bess [88]

The correct answer to this question is color coding.

Excel makes formulas easier to identify because they color code the cell reference with the corresponding cell in the worksheet. For example, if cell A1 in the formula is in blue, then the border around A1 will also be blue.

4 0
4 years ago
Which of the following are some popular debugging techniques?
topjm [15]

Answer:

a fix any syntax bugs. I looked it up on the internet so you should be good good luck on your test

8 0
3 years ago
Match the different sources of payments to their descriptions. an electronic device that aids consumers to make online payments
LekaFEV [45]

<u>Automatic Draft-</u> A convenient payment method where funds are automatically debited from your account.

<u>Cash-</u> The physical form of currency.

<u>Credit Card-</u> Allows you to make a purchase and pay for it later.

<u>Digital Wallet-</u> An electronic device that aids consumers to make online payments through various websites.

For anyone still looking, hope this helps.

6 0
3 years ago
Other questions:
  • Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expres
    11·1 answer
  • A single point of failure is a piece of hardware or application that is key to ________________________.
    8·1 answer
  • Ok so another weird question! So if you know what google drive is and how to upload a video why does it keep adding hours! it ke
    11·1 answer
  • alguem por favor poderia me falar que jogo sera mais pesado tanto em qualidades graficas ou em tudo:dragons dogma dark arisen ou
    11·1 answer
  • 40 is 20 % percent of what?​
    9·1 answer
  • True or False: <br> The object reference can be used to polymorphically store any class in Java.
    13·1 answer
  • 100 POINTS!! Help me out please I need help with this!!
    12·1 answer
  • Which is an appropriate strategy for using a workplace blog?
    9·1 answer
  • Which of the following algorithmic efficiencies would be considered LEAST efficient?
    8·1 answer
  • A diminished triad can be indicated by
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!