Im using both division and mod or thats whati think. can someone tell me if im doing something wrong here?Code:printf("Twenties: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS);
change_in_cents % CENTS_IN_TWENTY_DOLLARS;
Printable View
Im using both division and mod or thats whati think. can someone tell me if im doing something wrong here?Code:printf("Twenties: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS);
change_in_cents % CENTS_IN_TWENTY_DOLLARS;
That will be treated as two lines.
In this line:
the division is performed and the integer result is printed.Code:printf("Twenties: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS);
And in the second line, you are just performing the modulus operation but not assigning the result anywhere.
If you are trying to print both, then something like this can be done:
I didn't tested the code.Code:printf("Twenties: %d.%d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS, change_in_cents % CENTS_IN_TWENTY_DOLLARS);
:wave:
@ mattkeem,
For future reference could you please put a reference to what the question your ask is in the thread title rather than "help please" it will allow users to determine if they would be able to help or not. Also, it would help other people looking for an answer to the same problem.
Sorry about that ill reference it better next time. However im not trying to get two outputs but only one. What im trying to do is just say if i purchased simething for 30 dollars and u gave them a 100 dollar bill. You should get 3 twenties and one ten. Tats what im trying to display. I got everything right but the displaying how many twenties and ten i cant seem to do it
Then try something like this:
:wave:Code:printf("Twenties: %d\n Tens: %d \n" , change_in_cents / CENTS_IN_TWENTY_DOLLARS, change_in_cents % CENTS_IN_TWENTY_DOLLARS);