I'm very new to C. I want to add two one dimensional integer array name a[10] b[10].
I want to put the result in a 2dimentional array c[5][2] like
c[i][j] = a[i]+b[i];
But if I use 2 for loops then how can I access a[9],b[9] value. So I want to use a single for loop which perform a[i]+b[i] and puts the result in c[i][j].
Can anyone tell me how to do this?
- How do I put the value in 2dimensional array using single for loop?
- How do I print the value of 2dimensional array using single for loop?
- Please don't mind my English or question formatting as I'm very poor at English.
a[i]+b[i]inc[i][j], but how doesjaffect the calculation?for (i=0; i<2; i++) for (j=0; j<5; j++) c[i][j] = a[i*5+j] + b[i*5+j];