Portugol expecting a value of type "real"

0

I have a problem with my pseudocode, when I run it it says:

  

the data entry of the program expected a value of type 'real', but no value was informed or the value informed 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)
            {

            }       
    }
}

    
asked by anonymous 10.04.2014 / 20:37

2 answers

3

You have a logic error that is missing cont if not it will always be less than QTD

In this 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)
    
10.04.2014 / 20:49
7

Your% loop of% loop is wrong, it looks like this:

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

While it should look 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 faça-enquanto in your code you had written the stop condition twice.

Another error that you would find after fixing your loop repetition is the counter that does not increment, so you would be in an infinite loop

PS: Remember to indent your code

    
10.04.2014 / 20:47