Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. [Programming] [30 points] Write a function double parallel (double ri, double

ID: 3594360 • Letter: 2

Question

2. [Programming] [30 points] Write a function double parallel (double ri, double r2 ) to compute the resistance of two parallel resistors r and r. Note that it is equal to Write a function to compute the resistance of two serial resistors r, and r. Note that it is equal tor +r Use the two functions to compute the resistance of the following network. Your program should ask the user to enter the value of r in the following diagram, and it displays the resistance of the following network. Hint: The resistance of the following network can be computed by using the expression serialfr1, paralleftr2, r3)) r3 MacBook Air

Explanation / Answer

#include<stdio.h>

double parallel(double r1, double r2);

double series(double r1, double r2);

int main()

{

double r;

double parallelResistance, seriesResistance, seriesResistance1,total;

printf("Enter the resistance value: ");

scanf("%lf", &r);

//calculate the total resistnce for the given figure

//first calculate parallelResistance

parallelResistance = parallel(r, r);

//now parallelResistance and resistance r are in series, calculate total resistance using series fnction

seriesResistance = series(r, parallelResistance);

//now calculate one more series connection of r and r

seriesResistance1 = series(r, r);

//seriesResistance and seriesResistance1 becomes series ,, hence calculate total resistance using series functionas below

total = series(seriesResistance, seriesResistance1);

printf("Total resistance of the given ciruit is: %.2lf ", total);

}

double parallel(double r1, double r2)

{

double r;

r = (r1*r2) / (r1 + r2);

return r;

}

double series(double r1, double r2)

{

//for series ,total resistance will be some of their resistant

return r1 + r2;

}

----------------------------------------------------------------------------------------------------------

//output1

Enter the resistance value: 1.2
Total resistance of the given ciruit is: 4.20

//output2

Enter the resistance value: 1.5
Total resistance of the given ciruit is: 5.25

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote