Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please can this be done in C not c++ and can it have comments in the code to explain the structure of the code and

please can this be done in C not c++ and can it have comments in the code to explain the structure of the code and can the variable names be at least 6 characters long

image text in transcribed

Revise the code below to include the random number generator, rand() or srand(), to generate random resistor values between tolerance limits for each resistor. Hence calculate the equivalent circuit resistance for the circuit in Figure above. Present the results to demonstrate the variation in equivalent circuit resistance for 10 different sets (R1, R2 and R3) of randomly generated resistor values.

please add a sample of the output screen

#include #include

int main() { float R1, R2, R3, RPar, RTot_max, RTot_min; float tol_R1, tol_R2, tol_R3;

char choice;

do { printf("Enter the value of R1 in ohms: "); scanf_s("%f", &R1);

printf("Enter the tolerance of R1 in percent: "); scanf_s("%f", &tol_R1);

if (R1

printf("Enter the value of R2 in ohms: "); scanf_s("%f", &R2);

printf("Enter the tolerance of R2 in percent: "); scanf_s("%f", &tol_R2);

if (R2

printf("Enter the value of R3 in ohms: "); scanf_s("%f", &R3);

printf("Enter the tolerance of R3 in percent: "); scanf_s("%f", &tol_R3);

if (R3

// Calculate the tolerance limits for each resistor float tol_R1_val = R1 * tol_R1 / 100; float tol_R2_val = R2 * tol_R2 / 100; float tol_R3_val = R3 * tol_R3 / 100;

// Calculate the total resistance of resistors in parallel with tolerance RPar = 1 / ((1 + tol_R2 / 100) / (R2 + tol_R2_val) + (1 + tol_R3 / 100) / (R3 + tol_R3_val)) - tol_R1_val;

// Calculate the maximum total resistance of the circuit RTot_max = R1 + RPar + tol_R1_val + (tol_R2_val + tol_R3_val) * (R1 + RPar + tol_R1_val) / (R2 + tol_R2_val + R3 + tol_R3_val);

// Calculate the minimum total resistance of the circuit RTot_min = R1 + RPar - tol_R1_val - (tol_R2_val + tol_R3_val) * (R1 + RPar - tol_R1_val) / (R2 - tol_R2_val + R3 - tol_R3_val);

printf("The equivalent resistance between A and B at maximum tolerance limit is %.2f ohms. ", RTot_max); printf("The equivalent resistance between A and B at minimum tolerance limit is %.2f ohms. ", RTot_min);

if (RTot_max > RTot_min) { printf("Combination of minimum tolerance limits gives the minimum equivalent circuit resistance. "); } else if (RTot_max

printf("Do you want to enter new values (y)? "); scanf_s(" %c", &choice);

} while (choice == 'y');

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

11.3 Define pay equity and explain its importance today.

Answered: 1 week ago