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

Resistors have a manufacturers tolerance such that the actual value is guaranteed to be within the tolerance limits. For example, a resistor of 10k ohms with a 2% tolerance is shown as 10k 2%. The actual value of the resistance is expected to be within 9800 ohms to 10,200 ohms.

Revise the code below for it to include resistor tolerances and to calculate the equivalent resistance of the circuit in Figure 2, when the resistor values are set at their, a) maximum tolerance limit and b) minimum tolerance limit. Hence determine what combination of tolerance limits gives, a) the minimum equivalent circuit resistance and b) the maximum equivalent circuit resistance.

#include

#include

int main()

{

float R1, R2, R3, RTot, RPar;

char choice;

do

{

printf("Enter the value of R1 in ohms: ");

scanf("%f", &R1);

if (R1

{

printf("Invalid value! R1 must be greater than 0. ");

continue;

}

printf("Enter the value of R2 in ohms: ");

scanf("%f", &R2);

if (R2

{

printf("Invalid value! R2 must be greater than 0. ");

continue;

}

printf("Enter the value of R3 in ohms: ");

scanf("%f", &R3);

if (R3

{

printf("Invalid value! R3 must be greater than 0. ");

continue;

}

// Calculate the total resistance of resistors in parallel

RPar = 1 / (1/R2 + 1/R3);

// Calculate the total resistance of resistors in series

RTot = R1 + RPar;

printf("The equivalent resistance between A and B is %.2f ohms. ", RTot);

printf("Do you want to enter new values (y)? ");

scanf(" %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

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions