Find the Bug in this code .

#include <stdio.h>

void initializeArray(int arr[]) {
int size = sizeof(arr) / sizeof(arr[0]); // Incorrect way to find the array size

for (int i = 0; i < size; ++i) {
arr[i] = i * i;
}
}

void printArray(int arr[]) {
int size = sizeof(arr) / sizeof(arr[0]); // Incorrect way to find the array size

for (int i = 0; i < size; ++i) {
printf("%d ", arr[i]);
}

printf("\n");
}

int main() {
int myArray[10];

initializeArray(myArray);
printArray(myArray);

return 0;
}
Was this page helpful?