error (expected to find SO ) in visualg

Asked

Viewed 375 times

0

algoritmo "qual e o maior valor [vetor]"
var
   valores:vetor[1..4] de real
   cont:inteiro
   maior:real
inicio
      cont<-1
      maior<-0
      enquanto cont<=4  faca
               escreva("Qual e o",cont,"º Valor: ")
               leia(valores[cont])
               cont<-cont+1
               se valores[cont] < valores[maior] entao
                  valores[maior] <- valores[cont]
               fimse

      fimenquanto
      escreva("ANIMAAAAAAAAAAAL",valores[maior])
fimalgoritmo

There’s my (pseudo code) I don’t know what to do

  • In the code posted I could not find where could give the missing error of "then". However note that you assign 0 to the variable maior and uses it as the vector index valores except that the vector has the indices ranging from 1 to 4. I believe I should do: maior <- 1 .... se valores[cont] < valores[maior] entao maior <- cont fimse cont<-cont+1, in addition to declare maior as a whole.

No answers

Browser other questions tagged

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