0
I have the following error in my code: expected primary-expression before"int"
#include<stdio.h>
#include<stdlib.h>
void imc(float massa_corporal[3], float peso[3], float altura[3], int i){
for (i=0; i<3; i++){
printf ("\nInforme seu peso: ");
scanf ("%f", &peso[i]);
printf ("Informe sua altura: ");
scanf ("%f", &altura[i]);
massa_corporal[i]= peso[i] / (altura[i]*altura[i]);
}
for (i=0; i<3; i++){
printf ("imc[%d]= %f\n",i , massa_corporal[i]);
}
}
int main(){
float massa_corporal[3], peso[3], altura[3];
int i;
imc (massa_corporal[3], peso[3], altura[3], int i);
}
Which line is the error in?
– Pedro Roweder
line 25, in the call of the IMC function.
– Gabriel Ferreira
Just take the int in the function call. Now: what is the sense of you passing as a parameter a variable that will only be used in an auxiliary way (only an index) in the body of the function? You have to call the function of the form: imc (massa_corporal, weight, height, i); otherwise you will be referring to a specific item of the array, which, by the way, will be outside the limits of the array.
– anonimo
Comment at the end of the line with error
// erro aqui
, pq does not even have 25 lines of code in this excerpt.– mari