Consider I have an array A={-4, 2, 2}, {3, -3, 3}, {6, 6, 0 } I want to access column wise.Col={-4,2,2} col_0={3,-3,3} col_1={6,6,0} I have tried something like this yet I am not getting output Can anyone help me. I am beginner in c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define rows 3
#define col 3
int main()
{
int matrix_A[rows][col]=
{
{-4, 2, 2},
{3, -3, 3},
{6, 6, 0}
};
int col[rows];
int col_0[rows];
int col_1[rows];
int n;
for(n=0;n<rows;++n)
{
col[n]=matrix_A[n][0];
col_0[n]=matrix_A[n][1];
col_1[n]=matrix_A[n][2];
}
print("%lf",col[n]);
print("%lf",col_0[n]);
print("%lf",col_1[n]);
}
nwill be 3 after the loop so it will be out of bounds, as index is 0...2