My initial program runs through the compiler fine but it isn't calculating the answer correctly, I'm at a loss as to why. If I input something as simple as 1 for each question I get a 10 digit answer for the total.
#include <iostream>
#include <stdlib.h>
int main ()
{
using namespace std;
int PB, EB, CC;
int Total;
cout << "What is the phone bill for this month? ";
cin >> PB;
cout << "What is the electric bill for this month? ";
cin >> EB;
cout << "What is the Credit card bill for this month? ";
cin >> CC;
Total = PB+EB+CC;
cout << "Total: " << Total << endl;
system("pause");
return 0;
}
Well, you're performing the calculation before you even get the data from the user, so there's no way C++ could have the correct values; you're probably getting garbage values because the variables have no initial values when you add them up.