Why does C language acts like this
#include <stdio.h>
#include <stdlib.h>
int main()
{
const int size = 3;
double a[size];
for(int n=0; n<size; ++n){
a[n] = n;
printf("%d,%d\n",n,n+1);
}
}
Output is
0,1
1,2
2,3
But When i do this
#include <stdio.h>
#include <stdlib.h>
int main()
{
const int size = 3;
double a[size];
for(int n=0; n<size; ++n){
a[n] = n;
printf("%d,%d\n",a[n],n+1); //change is here
}
}
Output is :
1,1
2,2
3,3
Why does the value changes just by replacing n
and a[n]
which are same?