#include <iostream>
#include <cmath> /// Headers used by C++ compilers
#include <cstdlib>
#include <stdio.h>
double acidvol;
double acidconc;
double basevol;
double acidmol; ///Declarations for the variables used in this program.
double baseconc;
double basemol;
usingnamespace std;
int main()
{ /// Main body
titrations:
cout << "Titrations calculator V 0.1";
cout << "\n";
cout << "This program assumes that units of volume are in dm^3";
cout << "\n";
cout << "\n";
cout << "What was the concentration of the acid you used? (mol/dm^3): ";
cin >> acidconc;
cout << "\n";
cout << "What was the volume of acid used? (dm^3): ";
cin >> acidvol;
acidmol = acidconc * acidvol;
cout << "\n";
cout << "What volume of your base was used? (dm^3): ";
cin >> basevol;
acidmol = basemol;
baseconc = basemol / basevol;
cout << "\n";
cout << "One mol of the acid reacts with one mol of the base, so...";
cout << "\n";
cout << "\n";
cout << "Strength of acid is: " << acidmol << " moles";
cout << "\n";
cout << "\n";
cout << "The concentration of your base is: " << baseconc << " moles/dm^3";
cout << "\n";
cout << "\n";
cout << "Press enter to continue";
getchar();
getchar();
system ("cls");
goto titrations;
}
The problem is that the values for the conc of the base and the str of the acid don't calculate- I always end up with 0.
On line 37 you assign acidmol the value of basemol, discarding the previously calculated value of acidmol for the junk in the uninitialized variable basemol.
Then you do some calculations with the junk in the uninitialized variable basemol.
edit: Oops. Since basemol is a global variable, it was initialized to 0.