// Compute Molecules from Mass #include #include using namespace std; int main() { cout << "Enter mass of hydrocarbon (in grams)\n" << "followed by the number of carbon atoms\n" << "followed by the number of hydrogen atoms\n" << "(e.g. 10.5 2 6): " ; double Mass; int CarbonAtoms; int HydrogenAtoms; cin >> Mass >> CarbonAtoms >> HydrogenAtoms; const int CarbonAMU = 12; const int HydrogenAMU = 1; long int FormulaWght = (CarbonAtoms * CarbonAMU) + (HydrogenAtoms * HydrogenAMU); const double AvogadroNbr = 6.02e23; double Molecules = (Mass / FormulaWght) * AvogadroNbr; cout << Mass << " grams of a hydrocarbon\nwith " << CarbonAtoms << " carbon atom(s) and " << HydrogenAtoms << " hydrogen atom(s)\ncontains " << Molecules << " molecules" << endl; return 0; }