I couldn't compile it. You may want to check the type on the function parameter called total that you're passing around. In main it's a double, but you're passing it as an int. I'm surprised your compiler isn't complaining.