Good afternoon guys, all right?
I have an exercise here from the Faculty of Algorithms I, follow the statement below:
Write an algorithm that requests the age of several people (USE REPEAT). Enter the total number of people under 25 and the total number of people over 50. The program ends when age is negative (It should not be used in counting).
I've done the code so far, just the repetition. I'm wondering how to check the ages to report the totals.
Code so far:
algoritmo "APS05"
var
idade:inteiro
inicio
repita
escreva("Idade: ")
leia(idade)
ate (idade<0)
fimalgoritmo
Thank you in advance for your help.
[RESOLUTION]
repita
escreva("Idade: ")
leia(idade)
se (idade>=0) e (idade<25) entao
contMenos25 <- contMenos25 + 1
fimse
se (idade>50) entao
contMais50 <- contMais50 + 1
fimse
ate (idade<0)
escreval("Menores que 25: ", contMenos25)
escreval("Maiores que 50: ", contMais50)