Okay, I literally just began C++ programming and thus far, I'm loving it. BUT I do need some guidance. I'm attempting to write a program so solve an equation. The equation is F = k q1 q2 / r 2.
// Input Section
cout << "What is the charge of particle 1 in Coulombs ?" ;
cin >> Charge_1;
cout << "What is the charge of particle 2 in Coulombs ?" ;
cin >> Charge_2 ;
cout << "What is the distance between particle 1 and particle 2 in meters ?" ;
or input cmath library --- #include<cmath> and write force = c_constant*charge1*charge2 / pow(meters,2);
pow is standart function which returns double ....your error said that your language haven't " ^ " operand
How would I go about changing the output to not be in scientific notation? For example, making the answer "Force" be printed to a fixed format using 5 digit precision.
// Input Section
cout << "What is the charge of particle 1 in Coulombs? " ;
cin >> Charge_1;
cout << "What is the charge of particle 2 in Coulombs? " ;
cin >> Charge_2 ;
cout << "What is the distance between particle 1 and particle 2 in meters? " << endl;
cin >> Meters;
//Output Section
cout << " Charge of Particle 1: " << Charge_1 << " Coulombs" << endl;
cout << " Charge of Particle 2: " << Charge_2 << endl;
cout << " Distance between both particles: " << Meters << endl;
cout << " Force: " << Force << endl;
cout << " Force: " << setprecision (5) << Force << endl;
cout << " This is how we doooooo it!\n";
return 0;
Yeah, I did that but it still comes out as scientific notation. I'm trying to achieve two forms of the answer. One in scientific and one in a 5 fixed digit precision form. Do I need to alter something else?