Multiple choice

What will be the output of the following function?

include<stdio.h>

void fun(int *f) { *f = 10; } void main() { const int arr[5] = {1,2,3,4,5}; fun(&arr[3]); printf(“%d”,arr[3]); }

  1. 10

  2. 4

  3. 3

  4. Error

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The array 'arr' is declared as const, meaning its contents are read-only. Passing the address of a const element to a function that attempts to modify it through a non-const pointer is a violation that results in a compiler error.