Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
I'm having trouble getting the the modulo function to work in greedy using this code
int result = 0.0;
printf("SHOW ME WHAT YOU GOT: ");
float paid = GetFloat();
while (paid >= 0.25)
result = (paid/0.25) - (paid % 0.25);
paid = paid - 0.25;
while (paid >= 0.10 && paid < 0.25)
result = (paid/0.10) - (paid % 0.10);
paid = paid - 0.10;
The error says that 'invalid operands to binary expression ('double' and 'double'). How do I fix this?
17.6k33 gold badges2525 silver badges100100 bronze badges
asked Sep 29, 2015 at 20:27
K. RoeK. Roe
1955 bronze badges
Modulo only works with integers. You are attempting to apply it to a float.
If this answers your question, please click on the check to accept. Let's keep up on forum housekeeping. ;-)
answered Sep 29, 2015 at 20:31
Cliff BCliff B
66.7k44 gold badges3131 silver badges5656 bronze badges
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged