suppose user has given us floating point number(like 0.37$) and we want it to covert into decimal by roundingoff (mayb such that it doesn't affect on answer) and then use modulus operator on them.
i have been working on project that says take amount of money from user and return back such that first use biggest possible coin(quarter,dime,nickel and penny ) and give output how much coin used up in returning back.
I wrote program it worked correctly but each time it gives me one coin less,when i debug with cout at every level problem appears on the last stage when it compensate with penny(0.01)[when a penny subtract with 0.02 it gives output of 0.009999 instead 0.01..that's creating problem]
So i decided how about if i convert float into decimal and use modulus operator and use its remainder to give it next possible coin.
while(coin can be used)
counter++ //coin counter
remainder = remainder%quarter(could be penny,nickel etc) //currently working as user_input = user_input-quarter(etc)
each time coin increase
input amount decreases