So i am trying to make one of my first very simple math programs in c++. the problem is that
i can't seem to get the function potodds to do what i want. There is no problem in getting it to multiple the two variables (x,y)
that works perfectly fine. the problem occurs when i try to replace return x*y*100
with return (x/y)*100
. in this case it always return the value 0?
Hopes that someone out there can help me pinpoint my mistake.
The code looks like this:
#include "stdafx.h"
#include <iostream>
int x;
int y;
int potodds(int x, int y) {
return x * y * 100; //(x/y)*100;
}
int main() {
using namespace std;
cout << "what's the size of the pot?" << endl;
cin >> y;
cout << "what's the size of the bet?" << endl;
cin >> x;
cout << "your potodds are:" << endl;
cout << potodds(x, y) << endl;
return 0;
}
Thanks to Ebyrob i got the solution.
the problem that I was having was that I was trying to divide an integer, that was assigned a decimal value and by definition an integer can only contain whole numbers. The result was that the integer was rounded down to zero.