Problem with C

-1

I have [Error] expected expression before '<=' token , with the following code:

#include <stdio.h>
#include <stdlib.h>
int main ()
{
    float VS, VF;
    printf ("valor do salario: ");
    scanf ("%f", &VS);
    printf ("valor de um financiamento: ");
    scanf ("%f", &VF);
    if (VF/VS)<=5
    printf ("“Financiamento concedido.");
    else
    printf ("Financiamento negado.");
    system ("PAUSE");
}

Now the program is jumping the answer:

    
asked by anonymous 03.04.2014 / 17:38

3 answers

3

Try to replace:

if (VF/VS)<=5

by

if ((VF/VS)<=5)

The error happens because if is expecting to find an expression of type boolean (true or false) within the parentheses that follow it, and in your case it is encountering a division (numeric value).

As for the second "error", the "response" is appearing before the system ("PAUSE"); message. To fix this replace:

printf ("“Financiamento concedido.");

by

printf ("Financiamento concedido.\n");

Where \n represents line break.

    
03.04.2014 / 17:41
3

The ideal would be to give one more study in the language, to avoid putting here posting every error that the compiler presents.

    
03.04.2014 / 17:44
1

Your error is in this if :

if (VF/VS)<=5

Try:

if ((VF/VS)<=5)
    
03.04.2014 / 17:41