I'm solving the following exercise:
Write an algorithm that calculates the mean of the numbers entered by the user, if they are even. Finish reading if user types zero (0)
However, when I type 0 to finish, it counts 0 as even number, and is dividing by an extra number.
algoritmo "semnome"
var
n,np,m,nnp:real
inicio
repita
escreval ("entre com um numero")
leia (n)
se n%2=0 entao
np<-np+1
nnp<-nnp+n
fimse
ate n=0
m<- nnp/np
escreval ("a media dos numeros é",m)
fimalgoritmo