Error of expression "if"

Asked

Viewed 62 times

-1

My code is giving this error in the first expression se:

"The expression was not started correctly. Enter the character '(' to fix the problem"

real m1, m2, m3
    escreva("\n Digite o peso da primeira moeda= ")
    leia (m1)
    escreva("\n Digite o peso da segunda moeda= ")
    leia (m2)
    escreva("\n Digite o peso da terceira moeda= ")
    leia (m3)
    se (m1< m2, m3) escreva ("\nA primeira moeda é mais leve")
    se (m2< m1, m3) escreva ("\nA segunda moeda é mais leve")
    senao escreva ("\nA terceira moeda é mais leve")

1 answer

1


There is no such syntax you used to compare. Read the documentation of language to use any resource. The correct syntax (without worrying if the logic is correct, because we are not even sure about the goal) would be:

se (m1 < m2 e m1 < m3)

Same goes for the other parole.

You are making two completely different comparisons that define whether something is smaller and the result of these comparisons are concatenated through the operator e which gives true if, and only if, the two expressions of his left and his right are true.

The syntax of se seems wrong too. Unless you’re in a different dialect. See documentation. We’re missing a entao. And maybe there’s one missing senao se to give the correct logic. If there is a dialect that uses keys, then you can see the question Help in Portugol (if and if chained) that has an example of how it works.

Browser other questions tagged

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