Okay this has to be one of the simplest programs I've ever written, but for some reason my end result is always 0, unless at_bats and hits are the same number which in turn makes the outcome 1. Seriously, what is my stupid brain doing wrong?
#include <iostream>
using namespace std;
int main( )
{
int at_bats, hits;
double batting_average;
cout << "How many at bats has the player had? ";
cin >> at_bats;
cout << "How many hits has the player had? ";
cin >> hits;
batting_average = (hits / at_bats);
cout << "The players batting average is, " << batting_average << ".\n";
Integer arithmetic is you problem. Your batting_average may be a double, but hits and at_bats are ints, so anything that involves only ints and division is gonna end up being a whole number.