Portugol expecting a value of the "real" type

Asked

Viewed 464 times

0

I have a problem in my pseudocode, when I run it informs that:

the data entry of the program expected a value of the 'real' type, but no value was informed or the value is of another type;

How to solve this?

programa
{
    funcao inicio()
    {
        real N1, N2, N3, MEDIA
        inteiro QTD, cont
        escreva("\nDigite a qualtidade de alunos que deseja calcular a media: ")
        leia (QTD)
        cont = 0
        (cont< QTD) faca
        {
            leia(N1)
            leia(N2)
            leia(N3)    
        } enquanto(cont< QTD)
        se (N2>=N3)
            MEDIA=(N1+N2)/2
        senao
            MEDIA=(N1+N3)/2
        se(MEDIA>=6)
            escreva("\nAluno aprovado, Media:\n", MEDIA)
        senao
            escreva("\nAluno reprovado, Media:\n ", MEDIA)
            {

            }       
    }
}

inserir a descrição da imagem aqui

  • 7

    first of all I would like to remind you that portugol expects a well defined syntax, and not a pseudo-code

2 answers

7

Your loop of repetition faça-enquanto is wrong, he’s like this:

(cont< QTD) faca
{
 leia(N1)
leia(N2)
leia(N3)    
} enquanto(cont< QTD)

While he should be like this:

faca
{
   leia(N1)
   leia(N2)
   leia(N3)    
   cont++  //incremento do contador
} enquanto(cont< QTD)

You should write the stop condition only after the enquanto in your code you had written the stop condition twice.

Another error you would encounter after fixing your loop loop is the counter that doesn’t increment, so you would be in an infinite loop

PS: Remember to code

  • the error still continues, when this does not happen when you ask me to type the note of each student is repeating itself endlessly without an exact result.

  • 1

    @matheusferreira yes, you are not incrementing your cont, note that I wrote this in the reply

  • 3

    Math with Math get along.

  • 1

    Solving Problems of Math?

3


There is an error of logic missing increment cont if not it will always be smaller want QTD

in that code add the line cont = cont + 1 after reading(N3)

  faca{
        leia(N1)
        leia(N2)
        leia(N3)    
 } enquanto(cont< QTD)

or your code will look like this:

    faca{
         leia(N1)
        leia(N2)
        leia(N3)    
        cont = cont + 1 //linha nova 
 } enquanto(cont< QTD)
  • @Deyel I tested here, it worked with the (cont< QTD) before the faça. when you try to print: (cont< QTD) he returns verdadeiro.

  • Okay, it helped me a lot, thank you very much, your name on the profile scared me at first, I thought I missed what? more why I was starting to use stackoverflow in a short time. Thank you.

Browser other questions tagged

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