Vous êtes sur la page 1sur 2

1.) What is an array?

Answer:

1.) In data storage, an array is a method for storing information on
multiple devices.
2.) In general, an array is a number of items arranged in some
specified way for example, in a list or in a three-dimensional
table.
3.) In computer programming languages, an array is a group of
objects with the same attributes that can addressed individually,
using such techniques as subscripting.
4.) In random access memory(RAM), an array is the arrangement of
memory cells.
2.) How to declare an array?
Answer:
For primitive types:
int[] myIntArray = new int[3];
int[] myIntArray = {1,2,3};
int[] myIntArray = new int[]{1,2,3};

For classes, for example String, it's the same:

String[] myStringArray = new String[3];
String[] myStringArray = {"a","b","c"};
String[] myStringArray = new String[]{"a","b","c"};

3.) Syntax on how to call an array on program?
Answer:

ARRAY array-name {number-of-elements} <$> <length> <array-
elements> <(initial-value-list)>;
Where:
Array-name is a SAS name that identifies the group of variables.
Number-of-elements is the number of variables in the group.
$ - specifies that the elements in the array are character elements.
Length specifies the length of the elements in the array that have
not been previously assigned a length.
Array-elements is a list of the names of the variables in the
group.
Initial-value-list is a list of the initial values for the corresponding
elements in the array.

4.) Enumerate and list down an array.
Answer:

1.) Single Dimensional Array:
a.) Single or One dimensional array is used to represent and store data
in linear form.
b.) Array is having only one subscript variable is called One-
Dimensional array.
c.) It is also called as Single Dimensional Array or Linear Array
2.) Multi Dimensional Array:
a.) Array having more than one subscript variable is called Multi-
Dimensional array.
b.) Multi Dimensional Array is also called as Matrix.

5.) Give example codes for each type of an array.
Answer:

a.) Single Dimensional Array.
int iarr[3] = {2, 3, 4};
char carr[20] = c4learn ;
float farr[3] = {12.5,13.5,14.5} ;
Syntax:
<data-type> <array_name> [size];

b.) Multi Dimensional Array.
int a[3][3] = { 1,2,3
5,6,7
8,9,0 } ;

Syntax:
<data-type> <array_name> [row_subscript] [column-subscript];

Vous aimerez peut-être aussi