how to use the POW (POTENCY) function in C

Asked

Viewed 59,790 times

1

Good afternoon guys, I’ve come this far.

#include <stdio.h>
#include <math.h>
int main(void)
{
float val_carro, juros_mensal = juros_mensal / 100, num_parcelas, cf;

printf("\n\n  Digite o valor do carro: "); //entrada variaveis
scanf("%f", &val_carro);
printf("\n  Digite o numero de parcelas: ");
scanf("%f", &num_parcelas);
printf("\n  Digite o juros mensal: ");
scanf("%f", &juros_mensal);

cf = (1 + juros_mensal);
cf = (cf pow num_parcelas);  // calculo coeficiente de financiamento
cf = (1 / cf);
cf = (1 - cf);
cf = (juros_mensal / cf);

printf("\n\n  O valor de cada parcela é: %f", cf); //exibe valor de cada parcela
printf("\n\n  O valor do carro é: %f", cf *= 3); // exibe valor total do carro
return 0;
}

only that on the line that is commented the financing coefficient, the error,

expected')' before 'num_parcels'

then I can’t solve it.

  • 3

    would not be so? cf = (Pow (cf,num_parcels));

  • then I have done so I have isolated all variaves together, and separated from the function and the error persists

  • pow is a C function, not an operator. To use it, as @Diego said, you need to call it as a function as follows: pow(base, expoente).

  • now I managed I left a space in the middle and had not rotated gave error, but I corrected now. Thank you very much!

  • I’ll post the answer, for the record.

1 answer

2


The line has a syntax error:

 cf = (pow(cf,num_parcelas)); 

Where:

pow(base, expoente);
  • Thanks @Diego but I was able to solve the problem and yes I was wrong anyway.

Browser other questions tagged

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