I’m trying to show 1 up to 10 in visualg,but is giving error in 1 line where theoretically everything is right

Asked

Viewed 133 times

0

Algoritmo "SUPER CONTADOR"
//  

Var
   N1,cont : Inteiro

Inicio

  repita

    escreval ("===================") 

    escreval("|     MENU        |")
    escreval ("===================")
    escreval ("| [1] De 1 até 10 |")
    escreval ("| [2] De 10 até 1 |")
    escreval ("| [3] Sair        |")
    escreval ("===================")
    leia (N1)
    cont <- 1
    enquanto(cont < 10) faca <- o visualg está endentificando o erro nessa linha
      escreva (cont)
     cont <- cont + 1
    fimenquanto
  ate (N1 = 3)
Fimalgoritmo
  • Error on line 1 or error on any line ? Visualg does not use point and comma ";"?

  • I’m not sure I can’t test the code at the moment. It seems that the loop does not use "()" parentheses in the expression. Ex enquanto cont < 10 faca instead of enquanto (cont < 10) faca Computer support

  • was the parentheses even worth there personal :)

1 answer

0

I switched the enquanto for repita and added the repeating structure: escolha-caso-fimescolha.

Var c,n,cont:inteiro

Inicio
cont <- 1
repita
      escreval("                 ")
      escreval("|===============|")
      escreval("|     MENU      |")
      escreval("|===============|")
      escreval("|===============|")
      escreval("| [1] de 1 a 10 |")
      escreval("| [2] de 10 a 1 |")
      escreval("| [3] para sair |")
      escreval("=================")
      leia(n)
      escolha (n)
      caso 1
           n <- 1
           c <- 1
           repita
                 escreva(c)
                 c <- c + 1
           ate(c > 10)
      caso 2
           n <- 2
           c <- 10
      repita
            escreva(c)
            c <- c - 1
            ate(c < 1)
      caso 3
           n <- 3
           se (n > 2) entao
           cont <- cont + 1
           fimse
      fimescolha
ate(cont > 1)
limpatela
escreva("Saindo...")

Browser other questions tagged

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