void func(int a[5]) {
int i;
for(int i=0;i<5;i++) {
if(i%2 == 0) a[i]++;
else a[i]--
}
}
What would be the contents of array a after executing this function, if before passing a is as below:
1.)2 1 4 3 6
>Solution :
What would be the contents of array a after executing this function
From your given code snippet, we can infer that even numbers in the array will be incremented by 1 and odd numbers would be decremented by 1. So the answer is that the contents of the array would be:
3 0 5 2 7
Check out the output of the program here for confirmation.