/* --------------------------------------------------------------------- // Figure 4.28: Computing resistance. // Compute the equivalent resistance of three resistors in parallel. // --------------------------------------------------------------------- */ #include void main( void ) { double r1, r2, r3; /* input variables for three resistances */ double r_eq; /* equivalent resistance of r1, r2, & r3 in parallel */ puts( "\n Computing Equivalent Resistance" ); printf( "\n Enter values of resistances #1, #2, and #3 (ohms) \n" " All resistances must be greater than 0: " ); scanf( "%lg%lg%lg", &r1, &r2, &r3 ); printf( " r1= %g r2= %g r3= %g \n", r1, r2, r3 ); r_eq = r1 * r2 * r3 / r1 * r2 + r1 * r3 + r2 * r3 ; printf( " The equivalent resistance is %g\n\n", r_eq ); puts( "\n Normal termination" ); } /* Correct Version: ------------------------------------------------** r_eq = r1 * r2 * r3 / (r1 * r2 + r1 * r3 + r2 * r3 ); printf( "\n The equivalent resistance is %g\n", r_eq ); ** ---------------------------------------------------------------- */