Visualg does not recognize Real type variable

Asked

Viewed 86 times

0

I’m doing a program at a school where the program should ask how many students, right after offering a "registration" for each student stating their name and grade. In the case of this code, when the program asks to read the note, it gives an error saying that the variable "note" was not declared to be the real type, but it was.

Follow the full code:

algoritmo "Escola"
// Função :
// Autor :
// Data : 13/01/2021
// Seção de Declarações
var
  NA, N, QA: Inteiro
  maior, nota: Real
  nome, MelhorAluno: Caractere
inicio
  Escreval ("--------------------------------")
  Escreval ("---  ESCOLA SANTA PACIENCIA  ---")
  Escreval ("--------------------------------")
  Escreval
  Escreval ("--------------------------------")
  Escreva ("Quantos alunos a turma tem? ")
  Leia (NA)
  Escreval("---------------------------------")
  Enquanto (N <= NA) faca
    QA <- QA + 1
    Escreval ("ALUNO", QA)
    Escreva ("Nome do aluno: ")
    Leia (nome)
    Escreva ("Nota de ", nome, ": ")
    Leia (nota)
    Escreval ("---------------------------------")
    Se (nota > maior) entao
      maior <- nota
      nome <- MelhorAluno
    FimSe
  FimEnquanto
  Escreval
  Escreval ("O aluno ", MelhorALuno, " foi o aluno que teve o maior aproveitamento.")
fimalgoritmo

  • You use the variables N, QA and maior without having assigned any value to them. As you do not change the value of N your test Enquanto (N <= NA) faca can stay true forever (infinite loop). What you are reporting when you ask for nota?

1 answer

0

It has some attributes with no value, examples, N, QA and higher, so declare the values before, just to be able to enter the "WHILE" "WHILE". Example, N = 0; greater=0,

AS LONG AS N(0) IS LESS THAN OR EQUAL TO NA(VALUE THAT PERSON WILL ASSIGN), HE ALREADY ENTERS THE WHILE.

Did you understand the reasoning ?

Browser other questions tagged

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