-
Notifications
You must be signed in to change notification settings - Fork 0
/
tankfreq.c
34 lines (31 loc) · 837 Bytes
/
tankfreq.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Compile with gcc -Wall -o tankfreq tankfreq.c -lm
The Lightning Stalker 2014 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main (int argc, char **argv)
{
unsetenv ("LC_ALL");
setlocale (LC_NUMERIC, ""); // This should give us digit grouping
if (argc == 3)
{
printf ("%'.3f\n",
1 / (
2 * M_PI * sqrt (
atof(argv[1]) * atof(argv[2]) * 1e-12
)
)
);
return (0);
}
else
{
puts ("tankfreq is an LC tank resonance frequency calculator.");
puts ("output is frequency in Hz\n");
puts ("Usage: tankfreq microfarads microhenries");
puts ("Example: tankfreq 3.3 0.86207");
puts ("Output should be: 94,360.861");
return (1);
}
}