What is the output of the following C code? #include<stdio.h> int main(){ int arr[5] = {1,2,3,4,5}; int *p = (arr+2); printf("%d", p[-1]); return 0; }

What is the output of the following C code?

#include<stdio.h>
int main(){
    int arr[5] = {1,2,3,4,5};
    int *p = (arr+2);
    printf("%d", p[-1]);
    return 0;
}
  1. a) 2
  2. b) 3
  3. c) undefined behaviour
  4. d) Compilation error

From the BCS Technical Cadre (CSE) October 2025 – 49th BCS Written (Special) (BPSC) exam, question 67 of 123.

More from this paper