Skip to content

Instantly share code, notes, and snippets.

@dillmo
Last active August 29, 2015 13:56
Show Gist options
  • Save dillmo/8865761 to your computer and use it in GitHub Desktop.
Save dillmo/8865761 to your computer and use it in GitHub Desktop.
Calculate the volume or number of particles in a mas using moles
/* Copyright (c) 2014 dillmo
* Licensed under the MIT License(http://opensource.org/licenses/MIT)
*
* A program I made for chemistry class. It calculates how many particles there
* are in a gas in moles, based on its volume in liters.
*/
#include <iostream>
using namespace std;
int main()
{
double volume, answer;
cout << "What is the volume of your gas?" << '\n';
cin >> volume;
answer = volume * (1/22.4);
cout << scientific << answer << " mol" << '\n';
return 0;
}
/* Copyright (c) 2014 dillmo
* Licensed under the MIT License (http://opensource.org/licenses/MIT)
*
* A program I made for chemistry class. It calculates the volume of a gas
* based on the number of particles in moles.
*/
#include <iostream>
using namespace std;
int main()
{
double moles, answer;
cout << "How many particles are there in moles?" << '\n';
cin >> moles;
answer = moles * 22.4;
cout << answer << " L" << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment