C Array Test 311) Which statements are correct about the program given below?
The correct option is (b). Explanation: In program the statement int arr[size]; produces an error, because we cannot initialize the size of array dynamically. Constant expression is required for initialize the size of array. For Example: int arr[20]; Therefore the code is erroneous since the statement declaring an array is invalid. 12) Are the expression &arr and arr different for an array of 15 integers?
The correct option is (a). Explanation: Yes, both mean two different things. 'arr' gives the address of first int, whereas the '&arr' gives the address of array of ints. Therefore the expression '&arr' and 'arr' are different for an array of 15 integers. 13) Is there any difference in the below declarations?
The correct option is (b). Explanation: No, both the declarations are same. It is a prototype for function fun() that accepts one integer array as parameter and an integer value is return. 14) What will be the output of the below program?
The correct option is (c). Explanation: Step 1: int arr[2]={20}; The variable arr[2] is declared as an integer array with size of '3' and it's first element is initialized with value '20'(means arr[0]=20) Step 2: printf("%d\n", 0[arr]); It prints the first element value of variable 'arr'. Therefore the output of the program is 20. 15) What will be the output of the program if an array begins with address 65486?
The correct option is (a). Explanation: Step 1: int arr[] = {10, 11, 12, 15, 23}; The variable 'arr' is declared as an integer array and initialized. Step 2: printf("%u, %u\n", arr, &arr); Here, the base address of the array is 65486. Hence the arr, &arr is pointing towards the base address of the array arr. Hence the output of the program is 65486, 65486 |