I'm trying to learn c++ and was using physics school work to try and make a program.
One electron carries a charge of 1.6*10^-19 coulombs(C) and the program should show how many electrons are required to carry a charge of the number of coulombs entered by the user.
1 coulomb/1.6*10^-19 = 6.25*10^18 but the answer I get from the program is 6.25e+018. How do I get it to show the answer as 6.25*10^18? Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <math.h>
usingnamespace std;
int main()
{
double e = 1.6*pow(10, -19);
cout << "enter the charge in coulombs: " << endl;
int C;
cin >> C;
cout << C/e << " electrons are required to carry a charge of " << C << endl;
return 0;
}