I would like to post on there but it's protected from people with low reputation... Maybe someone here appreciates my solution in C:
#include <stdio.h>
int main(int argc, char* argv[]){
int arr[1];
int a = 2;
int b = 2;
arr[1] = 3;
printf("%d", a+b);
return 0;
}
Explanation: I go out of bounds of the array arr, it only has one value but I access the second value. That's why b is likely to get overwritten with 3 and hence a+b=5
It's only likely, but not certain that a or b get overwritten. How your stack is laid out is entirely up to the compiler. arr[1] is already out of bounds, however, we don't know for certain what's immediately above the array.