error: assignment to Expression with array type

Asked

Viewed 95 times

-1

I’m having a problem where I assign values to the matrix and to the vector but I still have the attribution error. I’m new to the forum and I still don’t know how things work right, if information is missing or something was done wrong I correct; I thank you from now on.

const int OsEmpresarios = 4;
const int GanhosMensais = 4;

float SalariosEmpresarios [4][4] = {0};
float MediaSalarios [4] = {0};

float Media = 0;
int empresario = 0, salario = 0;

printf("Digite os salários do 1° empresário:\n");

for (empresario = 0; empresario < OsEmpresarios; ++empresario){
for (salario = 0; salario < GanhosMensais; ++salario){
    scanf("%f", &SalariosEmpresarios [empresario][salario]);
    Media += SalariosEmpresarios [empresario][salario];
}
MediaSalarios = Media / 4;
Media = 0;
printf("digite os salários do %i° empresário:\n", empresario + 2);
}

for (empresario = 0; empresario < OsEmpresarios; ++empresario){
    printf("A média salarial do empresario %i° = %.2f\n", empresario + 1, MediaSalarios[empresario]);
 }

1 answer

0


I analyzed the code and realized that Mediasalarios is a vector, so it is necessary to pass the position you want to assign to the value of the Average of wages, so the right would be:

MediaSalarios[empresario] = Media/4;
  • Nice guy, thank you very much, that’s really what was missing

  • Could you put as a right answer? Last thing there, as it is inside a for, the position you want would be: entrepreneur. Getting: Mediasalaries[entrepreneur] = Media/4;

  • I did it, it was something I really forgot, and I just came to remember it now. of course I can, your answer is correct, the only thing, I don’t know where I can attribute to an answer that it is correct

  • Next to my reply has an option mark as correct by clicking on the green symbol below the vote button.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.