# Parallel resistance in electric circuits in C [duplicate]

What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit.

Using scanf

float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();}


Using command-line arguments

#include<stdlib.h>
float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/atof(v[i++]);printf("%f",1/r);}


Thanks

• Your first program doesn't halt. Is it intend behavior? – tsh Dec 4 '19 at 5:49
• For a tips question, please include an exact description of what the code is required to do, and ideally some test cases. That way we tell what's necessary and what is incidental to your chosen implementation. – xnor Dec 4 '19 at 7:34
• I've marked this as a duplicate because it has almost exactly the same title, and there exists a C answer there – Jo King Dec 4 '19 at 9:29