Question discussion

What will be the output of the following code (assume size of int as 4 bytes in the system)?

358840Medium DSSSB TGT Computer Science 0 replies 0 views
0
What will be the output of the following code (assume size of int as 4 bytes in the system)?
#include<stdio.h>
int main() {
    int arr[5] = {1, 2, 3, 4, 5};
    printf("%lu", sizeof(arr));
    return 0;
}
  • A20
  • B5
  • Ccompile time error
  • D4
Correct answer: A

Explanation

arr has 5 integers of 4 bytes each, so sizeof(arr) = 20.

Discussion 0

Nobody has replied yet. Start the discussion!