Finish repeat loop Repeat Visualg loop

Asked

Viewed 1,729 times

1

When we use the repita along with the ate at the end of the block, we should also use the fimrepita? If not, when we use this?

algoritmo "semnome"
var
   t,n,i,m:inteiro
inicio
   i<-0
   repita
      escreval ("entre com a nota")
      leia (N)
      escreval ("entre com a nota")
      leia (M)
      t<-(n+m)\2
      escreval ("a media do aluno foi:",t)
      i<-i+1
   ate i=5
fimalgoritmo

1 answer

2

The fimrepita is used when there is no pre-defined stop condition, such as the ate. That is, when it repeats until a stop condition occurs, as below:

var x: inteiro
x <- 0
repita
    x <- x + 1
    se x = 10 entao
        interrompa
fimrepita

It serves to define how far the code block of your command will repeat. But, when you use the command ate, it is not necessary to use the fimrepita.

Reference

Browser other questions tagged

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