Problems in passing arguments by parameter

Asked

Viewed 75 times

0

I’m having trouble passing arguments through parameters. The error occurs in the row 23 column 5 and it’s like this:

Too few Arguments to Function 'imc'

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include <unistd.h>

float imc(float tam, float pes);

int main()
{
    float altura;
    float peso;
    float resultado;

    printf("digite a sua altura ");
    scanf("%f",&altura);
    printf("\n\ndigite seu peso ");
    scanf("%f", &peso);

    imc(altura,peso);

    system("clear");

    printf("%f", imc(resultado));

    return 0;
}

float imc(float tam, float pes)
{

    return tam*pow(pes,2);
}

2 answers

4


If you repair your function imc is asking for two parameters: float imc(float tam, float pes).

In your printf you have printf("%f", imc(resultado));, that is, at the moment you are sending a parameter (resultado), will give parameter error.

For that not to happen:

resultado = imc(altura,peso);

system("clear");

printf("%f", resultado);
  • aaa vlw, I have to improve the way I write =P printf("%f", resultado=imc(altura, peso));

1

The problem is in the function call,

float imc(float tam, float pes)

Because in the line 23 the function imc asks for two arguments and you’re only going through one.

Browser other questions tagged

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