Consider the following array declarations in 'C' language: int array1[] = {2, 3); int array2[3] = {9}; What will be the output of the following print statement? printf(“%d, %d”, array1[1], 2[array2]):
Consider the following array declarations in 'C' language: int array1[] = {2, 3); int array2[3] = {9}; What will be the output of the following print statement? printf(“%d, %d”, array1[1], 2[array2]): Correct Answer 3, 0
Key Points
An array is defined as the collection of similar types of data items stored at contiguous memory locations. Arrays are the derived data type in C programming language which can store the primitive type of data such as int, char, double, float, etc. C array is beneficial if you have to store similar elements.
Array can be access i th index at array A,
A= i = *(A+ i) = *(i + A)
Given that,
int array1 = {2, 3);
int array2 = {9};
printf(“%d, %d”, array1, 2);
array1 is dynamic allocation of {2,3}.
array2 is three memory cells and stores 9 at 0th index of array2.
printf(“%d, %d”, array1, 2);
array1= 1st index at array1 = 3
2= 2nd index at array2 = 0
Hence the correct answer is 3, 0.