#include <stdio.h>
void receber_matriz(l, c) {
int M[l][c];
for (l = 0; l < 4 ; l++) {
for (c = 0; c < 4; c++) {
printf("\nInsira o valor do numero da linha: %d e da coluna: %d", l, c);
scanf("%d", &M[l][c]);
}
}
}
int main() {
int l = 0;
int c = 0;
receber_matriz(l, c);
return 0;
}
No math library required, as it is a simple input.
I understand that you can use the same function input variable to read from the keyboard in the matrix.
Variables can be initialized with 0, since they will enter the for the same way. Initialized with 0 would be the question of logic because programming is not just writing code. It could even have negative values, but it would not be ideal.
I could use a while for both of us. It would be shorter line of code, but has the detail of: the for is is when the end is known; the while is for noncountable repeat cases or unknown end.
Welcome to Stack Overflow! Please explain the problem better, and if possible include a example of code that reproduces what is happening, because your question is not noticeable. See Help Center How to Ask.
– Jorge B.
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero
Your
printf
is incorrect. Take a look at the documentation of the function. Also, the function is with wrong name -rebeber_matriz
– Leonardo Alves Machado