# Thread: Question: Illegal Operand Types

1. ## Question: Illegal Operand Types

Hi Everyone! First of all, please excuse the super simple for dummies question. I'm a total newbie to programming and i'm taking a C class online so it's difficult to get feedback and answers to questions.

In the below code, can someone please explain why I get an error for 'Left operand is type float / right operand is type const float'? I have spent hours trying to figure this out to no avail! And yes, this is a homework question, but i'm not looking for the complete answer, just help with this one error. Thanks in advance!

#include <stdio.h>
const float TAXRATE = 0.056;
int main(void)
{
float price;
int dollar, cent;

scanf("%f", &price);

dollar = price * TAXRATE
cent = price % TAXRATE;

printf("Item price \$%2f with sales tax is %d dollars and %d cents.", price, dollar, cent);

2. % is remainder after division, but it requires integers (the assumption is, if you're dividing floating-point values, that you want something like 3.85 rather than 3 remainder 6).

3. Oh, jeez. I knew it would be something simple! Looks like I need to rework my approach to the answer all together since the remainder function won't work. Thank you so much!

4. Originally Posted by barnbrat
Oh, jeez. I knew it would be something simple! Looks like I need to rework my approach to the answer all together since the remainder function won't work. Thank you so much!
You'd be doing that anyway, since (1) dividing by the tax rate isn't going to give you cents in the first place, and (2) you need to come up with a way to turn .4967423 into neither 49 cents nor 49.67423 cents nor 4967423 cents.