You mention non-integer numbers such as 0.75 and 0.8.
When you divide an integer by an integer, the program truncates the result to an integer.
You either need cast b to be a double or float, or (I would suggest) make fee() take in doubles instead of ints.
Also, when it has return a; followed by return b;, what does that look like as a result? Would it print both numbers with a space between them? |
I would review whatever tutorial you're reading about function structure/flow. A return call immediately exits out of the function.
1 2 3 4 5
|
int foo()
{
return 2; //Return statement is here! End of function!
return 3; //This is *never* called because something was already returned.
}
|
Also, I would read up on if-statements.
doesn't do anything because you have a semi-colon right after the statement.
You should format it like this instead
1 2 3 4 5 6
|
if (a*b == a*c - a) {
//do stuff
}
else {
//do other stuff
}
|
Edit: But also, if you do use doubles, be weary of the equality operator ==, as it will only return true if both numbers are
exactly the same.