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.

Related Questions

Comment on the output of the following C code.
#include int main(){ int a = 1; switch (a) case 1: printf("%d", a); case 2: printf("%d", a); case 3: printf("%d", a); default: printf("%d", a);}
A teacher asked the class to subtract 5 from 75.70% of the class said: 25. Their work was shown as: \(\begin{array}{*{20}{c}} {\begin{array}{*{20}{c}} 7&5 \end{array}}\\ {\underline {\begin{array}{*{20}{c}}\ { - 5} \ \ \ &{} \end{array}} }\\ {\underline {\begin{array}{*{20}{c}} 2&5 \end{array}} } \end{array}\) Which of the following describes the most appropriate remedial action that the teacher should take to clarify this misconception?
Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code: P → D* E* D → int ID {record that ID.lexeme is of type int} D → bool ID { record that ID.lexeme is of type bool} E → E1 + E2 {check that E1.type = E2.type = int; set E.type := int} E → !E1 {check that E1.type = bool; set E.type := bool} E → ID {set E.type := int} With respect to the above grammar; which one of the following choices is correct?