Last active
September 4, 2025 04:56
-
-
Save LightningStalker/48b9c77832698b213c64e6a1d89ccd31 to your computer and use it in GitHub Desktop.
Joules caclulater for capactor of size C being charged to Voltage V
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Capacitance + Voltage² -> joules calc | |
| * Project Crew™ 6/28/2025 | |
| */ | |
| #include <iostream> | |
| #include <cmath> | |
| #include <exception> | |
| using namespace std; | |
| int | |
| main(int argc, char * argv[]) | |
| { | |
| long double C, V; | |
| try | |
| { | |
| C = stod(argv[1]); | |
| V = stod(argv[2]); | |
| }catch (...) | |
| { | |
| cerr << "USAGE: $ " << argv[0] << " C(microfarad) V" << endl; | |
| return(EXIT_FAILURE); | |
| } | |
| /* J = ½CV² */ | |
| cout << 5e-7 * C * pow(V, 2.0) << endl; | |
| return(EXIT_SUCCESS); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment