- This topic has 1 reply, 2 voices, and was last updated 2 years, 3 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forums › Fórum Lógica de Programação: O Guia Completo › Fiz atribuindo o contador, um pouco diferente, mas deu o mesmo resultado
programa{
funcao inicio(){
inteiro contador = 1, numeroNegativo = 0
real a
enquanto(contador <= 5){
escreva(“Digite o valor “, contador, “: “)
leia(a)
se(a < 0){
numeroNegativo = contador
}
contador++
}
escreva(“Números negativos: “, numeroNegativo)
}
}
Olá Vianê, muito bom, porém observe o seguinte, dessa forma seu programa só armazenará a última posição negativa encontrada.
Fabio