"fimenquanto sem enquanto correspondente" error

Asked

Viewed 321 times

0

algoritmo "semnome"
var
   n,i,ma,me:inteiro
inicio
   i<-0
   me<-0
   ma<-0
   enquanto (i<21) faca
      Escreval ("insira um numero inteiro:")
      leia (n)
      se n<0 entao
         me<- me+1
      senao
         se n>0 entao
            ma<-ma+1
         fimse
         i<-i+1
      fimenquanto
      escreval ("a quantidade de numeros maiores inseridos foi:",ma)
      escreval ("e a quantidade de numeros menores inseridos foi:",me)
fimalgoritmo

1 answer

1


In your code, you have two se and only one fimse. Was missing the fimse to the first se. Your code should be like this:

algoritmo "semnome"
var
   n,i,ma,me:inteiro
inicio
   i<-0
   me<-0
   ma<-0
   enquanto (i<21) faca
      Escreval ("insira um numero inteiro:")
      leia (n)
      se n<0 entao
         me<- me+1
      senao
         se n>0 entao
            ma<-ma+1
         fimse
      fimse
      i<-i+1
   fimenquanto
   escreval ("a quantidade de numeros maiores inseridos foi:",ma)
   escreval ("e a quantidade de numeros menores inseridos foi:",me)
fimalgoritmo

The reason the error message refers to fimenquanto there was a block se opened, and therefore the expected would be a fimse. However, the compiler found a fimenquanto, that wasn’t what he expected.

  • got it, thanks

  • @If this answer solved your problem and there is no doubt left, mark it as correct/accepted by clicking on the " " that is next to it, which also marks your question as solved. If you still have any questions or would like further clarification, feel free to comment.

Browser other questions tagged

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