Matrix in C language

Hello everyone !!
I need to fill a matrix in a somewhat delicate way:
I have the number of columns and rows, but I need to fill it so that each column encodes its number in binary!!!
Basically, the matrix will contain only 1s and 0s...
If the number of columns = 5
and the number of rows = 3
the matrix would look like this:

1 0 1 0 1
0 1 1 0 0
0 0 0 1 1

HELP ME PLEASE !!

I’m waiting for you!!!
Configuration: Windows XP Firefox 2.0.0.9

3 answers

  1. Hello,
     #include <stdio.h> #include <math.h> #define C 5 //columns #define L 3 //lines int main() { int i,j; int tab[C][L]; for (i=0;i<C;i++) { for (j=0;j<L;j++) {if (((i+1) & (int) pow(2,j)) == (int) pow(2,j)) tab[i][j]=1; else tab[i][j]=0;} } for (j=0;j<L;j++) { for (i=0;i<C;i++) printf("%d ",tab[i][j]); printf("\n"); } return 0; } 
    0