Resistance Calculator

#include<stdio.h>
#include<math.h>
int main (void)
{
int i, n, r, s;
double rt = 0.0;
printf( "How many Resistor you want ( less than 5 ) :" );
scanf( "%d", &n);
printf( "Do want them Parellel or series\n 1 Parallel\n 2 Series\n" );
scanf( "%d", &s);

swith (s){
case 1:
for ( i = 1; i <= n; i++ ) {
printf( "R%d =",i );
scanf( "%d", &r );
rt = rt + pow ( r, -1 );
}
printf( "the total resistance Rt = %2.2f", 1/rt );
break;

No comments:

Post a Comment