Sum of rows and columns with each element being 1 or 0. C

I am supposed to create a code that where you you have to these things:

  1. input the amount of rows and columns

  2. input the sum of each row, and columns.(they don't have to be the same as long as bigger than 0.

  3. then you have to check if the sums are correct.

I've tried doing as a long array instead and checking when each row starts as well as doing it as a matrix but we haven't learned that. I'm coding in C, and what i'm asking for is useful tools I can use when doing this. A beginner coding in C as well.

#include <stdio.h>

int main() {
    int row,column;
    scanf("%d %d", row, column);
    int array[row][column],i;
    for (i=0; i<row; i++)


    return 0;
}

this is as far as i've gotten the problem is writing in a sum of one row and then comparing that.

1 answer

  • answered 2018-10-12 00:30 hamid crazy

    Consider this a comment! you should add a '&' in scanf to store the scaned value in the adresse of the variable so it would be scanf("%d %d",&row,&column);