-6

The code I have that keeps giving me the error. It says that the error is at the float total line of code.

float total = (decimal1*number1) % number 4;

What could be the problem with it?

enter image description here

 

Phani Kumar M
  • 4,564
  • 1
  • 14
  • 26
  • 1
    The remainder operator `%` only works on two integers. You are trying to apply it to a `float` and an integer. You might be looking for [`fmod`](http://en.cppreference.com/w/cpp/numeric/math/fmod) function. – Igor Tandetnik Sep 18 '17 at 01:11
  • 1
    The problem is that instead of showing a [mcve], this question contains a useless link to some external web site that can stop working at any time, rendering the question meaningless. And the real problem is that you have not read the [help] before posting your question. – Sam Varshavchik Sep 18 '17 at 01:12
  • So @SamVarshavchik The question contains the link that i put in through the insert picture on the post. Don't see how it is "useless". The real problem is that people like you take pride in trying to tear people down who are just asking a simple question after googling for the answer cant come up with what is needed. Since I have no idea what exactly to try and search for but Nonethe less looking through every link and nothing is helping. – ZeroJava Sep 18 '17 at 01:17
  • @IgorTandetnik Thank you. Ill try that out. You are a huge help. :) – ZeroJava Sep 18 '17 at 01:18
  • As explained in the [help], all questions on stackoverflow.com must include all pertinent information in the question itself, as plain text. Links to external web sites, that can stop working at any time, rendering the question meaningless, are not acceptable. Because this question does not follow the rules specified in the [help], it will be downvoted and closed for being off-topic. – Sam Varshavchik Sep 18 '17 at 02:42

1 Answers1

0

The issue is related to the modulo operator which expects a binary expression of two integers.

I'd suggest reading up a little on the rules of modulo and finding a way to adjust your code. Here is an answer about this and a suggestion how to go about fixing this error.

Why does modulus division (%) only work with integers?

Alex Top
  • 33
  • 6