WorksheetsComputer programming-Array
Total questions: 10
Worksheet time: 10mins
■An array is a group of memory locations that have ______________________________.
the same name and different type
the same name
the same name and the same type.
the different name and type
Two types of Array are:
1 Dimensional Array and 2 Dimensional Array
2 Dimensional Array and 3 Dimensional Array
Linear Array and Dynamic Array
Sequence Array and Non-Sequence Array
Declaration statement for an array named arr with size 5 is
int arr[0];
int arr[5];
int arr(5);
int arr[4];
Declaration and initialize statement for an array named number with 1.1, 2.2 and 3.3 is written as
float number[2] = {1.1, 2.2, 3.3};
int number[3] = {1.1, 2.2, 3.3};
float number[3] = {1.1, 2.2, 3.3};
int a[5]={1,2,3,4,5};
The statement to display the third element of an array a is
printf(“ Array a[2] = %d \n”, a[2]);
printf(“ Array a[3] = %d \n”, a[3]);
Statement to display the fourth element of the array arr.
int arr[5]={12,23,31,42,51};
printf(“ Array arr[4] = %d \n”, arr[4]);
printf(“ Array arr[3] = %d \n”, arr[3]);
The output will display:
3
4
5
Declaration statement of the array named x with 'u', 'i', 't' and 'm' will show as:
char x[4] = {'u', 'i', 't', 'm'};
char x[5] = {'u', 'i', 't', 'm'};
Printf statement to print all character in the array is
printf(" printing %s \n");
printf(" printing %c \n", arr);
printf(" printing %s \n", arr);
The output will display,
printing h
printing e
printing l
printing l
printing o
printing
h
e
l
l
o
printing h e l l o
