- #1
dE_logics
- 742
- 0
In the program below -
The statement 'counter[0][1] = 2;' changes the value of counter[1][0] to 2...and it was 4 previously.
Code:
#include<stdio.h>
char places = 4;
main()
{
char m = 3;
short i;
char counter[places - 2][1];
for(i = 0;i<=places-3;i++)
{
counter[i][0] = m;
m++;
counter[i][1] = i - i;
}
printf("%d \n", counter[1][0]);//Value of counter[1][0] = 4
counter[0][1] = 2;
printf("%d", counter[1][0]);//Value of counter[1][0] switches to 2 after the above statement...WHAT?
}
The statement 'counter[0][1] = 2;' changes the value of counter[1][0] to 2...and it was 4 previously.