Question discussion

What will be the output of the program ?#includeint main(){ int arr[1] = {10}; printf("%d", 0[arr]); return 0;}

305953Medium 1 reply 1,385 views
17
What will be the output of the program ?#include<stdio.h>int main(){ int arr[1] = {10}; printf("%d", 0[arr]); return 0;}
  • A1
  • B0
  • C10
  • D6
  • ENone of these
Correct answer: C

Discussion 1

0
CCommunity
10

>> int arr[1]={10}; The variable arr[1] is declared as an integer array with size '2' i.e. arr[0] and arr[1] and it's first element is initialized to value '10'(means arr[0]=10)
and arr[1] = garbage value or zero
>> printf("%d", 0[arr]); It prints the first element value of the variable arr.

Hence the output of the program is 10.