Skip to content

Instantly share code, notes, and snippets.

@hc3
Last active June 5, 2017 18:05
Show Gist options
  • Save hc3/b3238e6642f8d210bb1b9bf003f6c27f to your computer and use it in GitHub Desktop.
Save hc3/b3238e6642f8d210bb1b9bf003f6c27f to your computer and use it in GitHub Desktop.
Algoritmo "calculaTrocoHc3"
Var
valor_compra, valor_pago,troco:real
notas50,notas20,notas10,notas5,notas2,notas1:inteiro
Inicio
escreva("Digite o valor da compra :")
leia(valor_compra)
escreva("Digite o valor a pago :")
leia(valor_pago)
troco := valor_pago - valor_compra
escreval("Programa calcula troco - Hc3")
escreval("TROCO :",troco)
se troco >= 50 entao
notas50 := int(troco) \ 50
troco := troco % 50
se troco <> 0 entao
notas20 := int(troco) \ 20
troco := troco % 20
se troco <> 0 entao
notas10 := int(troco) \ 10
troco := troco % 10
se troco <> 0 entao
notas5 := int(troco) \ 5
troco := troco % 5
se troco <> 0 entao
notas2 := int(troco) \ 2
troco := troco % 2
se troco <> 0 entao
notas1 := int(troco) \ 1
troco := troco % 1
fimse
fimse
fimse
fimse
fimse
senao se troco >= 20 entao
notas20 := int(troco) \ 20
troco := troco % 20
se troco <> 0 entao
notas10 := int(troco) \ 10
troco := troco % 10
se troco <> 0 entao
notas5 := int(troco) \ 5
troco := troco % 5
se troco <> 0 entao
notas2 := int(troco) \ 2
troco := troco % 2
se troco <> 0 entao
notas1 := int(troco) \ 1
troco := troco % 1
fimse
fimse
fimse
fimse
fimse
escreval("NOTAS DE 50 :",notas50)
escreval("NOTAS DE 20 :",notas20)
escreval("NOTAS DE 10 :",notas10)
escreval("NOTAS DE 5 :",notas5)
escreval("NOTAS DE 2 :",notas2)
escreval("NOTAS DE 1 :",notas1)
Fimalgoritmo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment