Problem with the C

Asked

Viewed 121 times

-1

I’m with the [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 skipping the answer: inserir a descrição da imagem aqui

  • 1

    What did you mean by skipping the answer?

3 answers

3


Try to replace:

if (VF/VS)<=5

for

if ((VF/VS)<=5)

The mistake happens because the if is hoping to find an expression like Boolean (true or false) within the parentheses that follow, and in your case it is finding a division (numerical value).

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

printf ("“Financiamento concedido.");

for

printf ("Financiamento concedido.\n");

Where the \n represents line break.

3

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

  • the only problem I have that even I solve it I started a little while ago so I have no experience with the errors presented to me.

  • @Cache This fits as a comment, not an answer. But you’re right.

  • I’m sorry if I seemed a little rude, I didn’t mean to. I don’t know what material you are using for study, but I think there should be some basic examples about the use of parentheses and compound conditions.

  • thanks for the help, I managed to solve my problem.

1

Your mistake is in this if:

if (VF/VS)<=5

Tries:

if ((VF/VS)<=5)

Browser other questions tagged

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