Freedom to Offend

819,085 comments by 11,491 users Ceffer, HeadSet, Hircus, Tenpoundbass and 17 lurkers online now

GonzoReal
ignore (0) 2017 Jul 27, 8:06pm ↑ like (2) ↓ dislike (0) quote flag

Pseudocoded without arrays or loops using mod function. Not very elegant but time complexity is constant for any input.

amount = 0

remainder=0

quarters=0

dimes=0

nickels=0

pennies=0

Input amount from user

amount =amount X 100;. Get rid of decimals

remainder = amount mod 25

amount = amount - remainder

quarters = amount /25

amount = remainder

remainder = amount mod 10

amount = amount - remainder

dimes = amount / 10

amount = remainder

remainder = amount mod 5

amount =amount - remainder

nickels = amount / 5

pennies = remainder

output "Quarters =" quarters

output "Dimes =" dimes

output "Nickels =" nickels

output "Pennies =" pennies

Dusk at Squaw June 11