We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c488993 commit 4030170Copy full SHA for 4030170
joules.c
@@ -0,0 +1,29 @@
1
+/* Compile with gcc -Wall -o joules joules.c -lm
2
+ The Lightning Stalker 2023/12/14 */
3
+
4
+#include <math.h>
5
+#include <stdio.h>
6
+#include <stdlib.h>
7
+#include <locale.h>
8
9
+int main (int argc, char **argv)
10
+{
11
+ unsetenv ("LC_ALL");
12
+ setlocale (LC_NUMERIC, ""); // This should give us digit grouping
13
14
+ if (argc == 3)
15
+ {
16
+ printf ("%'.3f\n", 0.0000005 * atof(argv[1]) * \
17
+ powf(atof(argv[2]), 2));
18
+ return (0);
19
+ }
20
+ else
21
22
+ puts ("joules is a simple capacitor joule calculator.");
23
+ puts ("output is stored energy in joules\n");
24
+ puts ("Usage: joules microfarads volts");
25
+ puts ("Example: joules 33 330");
26
+ puts ("Output should be: 1.797");
27
+ return (1);
28
29
+}
0 commit comments