I'm doing the following exercise program:
Create an algorithm that reads the lower and upper limits of a range and print all odd numbers in the open interval and its summation (USE IT). Suppose the data you enter is for a decreasing interval.
My question is, how do I not display the digits? Because I should print the open interval, and in this, it should not display the numbers entered.
algoritmo "APS08"
var
inf, sup, soma:inteiro
i:inteiro
inicio
escreva("Digite o limite inferior: ")
leia(inf)
escreva("Digite o limite superior: ")
leia(sup)
para i de inf ate sup faca passo -1
se (i%2 = 1) entao
escreva(i)
soma <- soma + i
fimse
fimpara
escreval("")
escreval("Soma: ",soma)
fimalgoritmo
Can anyone explain how I do it?
[RESOLUTION]
algoritmo "APS08"
var
inf, sup, soma:inteiro
i:inteiro
inicio
escreva("Digite o limite inferior: ")
leia(inf)
escreva("Digite o limite superior: ")
leia(sup)
para i de sup-1 ate inf-1 passo -1 faca
se (i%2 = 1) entao
escreva(i)
soma <- soma + i
fimse
fimpara
escreval("")
escreval("Soma: ",soma)
fimalgoritmo