Find the bug

#include <stdio.h>
#include <stdlib.h>

int main() {
int *array = malloc(5 * sizeof(int));
int i;

for (i = 0; i <= 5; i++) {
array[i] = i * 2;
}

printf("Array values:\n");
for (i = 0; i < 5; i++) {
printf("%d\n", array[i]);
}

int value = 10;
int result = value / (5 - i);

free(array);
return 0;
}


Expected output:
0
2
4
6
8
Was this page helpful?