Looking for answers? Westonci.ca is your go-to Q&A platform, offering quick, trustworthy responses from a community of experts. Discover the answers you need from a community of experts ready to help you with their knowledge and experience in various fields. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

explain declaration and initialization of one and two dimensional arrays with example


Sagot :

The declaration and initialization of arrays involves creating and using the arrays

How to declare an array?

Assume the programming language is Java.

To declare and initialize an array, we make use of:

  • One dimensional array: Data-Type Array-name [] = {List of array values}
  • Two dimensional array: Data-Type Array-name [] [] = {List of array values}

Assume the array name of the one dimensional array is num, and the data type is integer.

The following can be used to declare and initialize the array to have 5 elements

int num [] = {1,2,3,4,5}

Assume the array name of the two dimensional array is num, and the data type is integer.

The following can be used to declare and initialize the array to have 2 rows and 3 columns

int num [][] = {{1,2},{3,4},{5,6}}

Read more about arrays at:

https://brainly.com/question/22364342