LAB ASSIGNMENT 2:
Part A (Lab2a.c):
Write a program that calculates the equivalent resistance of two
resistors in parallel.
Steps:
1. Explain the program to the user.
2. Prompt the user to enter values for the two resistors (R1 and
R2). Your statement to the user should have the following format
(for the first resistor value):
Enter resistor 1 value [ohms]:
3. Then scan in the resistor value (as a double). Do the same for the
second resistor.
4. Calculate the equivalent resistance of the parallel resistors
combination and using the formula REQ = (R1 * R2)/(R1 + R2)
4. Display the equivalent resistance REQ (don't forget the units). The
format of your output statement must be:
The equivalent resistance is 800.0 [ohms].
Technical Details:
Library Functions:
printf(), scanf() declared in the stdio.h include file
Variables:
double R1 resistor 1
double R2 resistor 2
double REQ equivalent resistance
Test cases:
R1=1000 ohms, R2=4000 ohms REQ=800 ohms
R1=1000 ohms, R2=1000 ohms REQ=500 ohms
R1=1000 ohms, R2=0 ohms REQ=0 ohms
Part B (Lab2b.c):
Write a program that calculates the voltage drop, V, across a resistor
(R) conducting current, I, using the following equation: V = IR (Ohm's
Law). In the same program, calculate the power dissipated within the
resistor using the equation: P = (V^2)/R.
You should do your own design on this problem, similar to the design
provided for part A above. That is, before programming, you should
determine the approximate steps your program will need to complete,
the variables you will need, and design some test cases.
Constraints:
1. There are only two user inputs (R, I) and two outputs (V, P).
2. Use proper units when prompting the user for inputs and displaying
the results. Units are: resistance - ohms, voltage - volts,
current - amps, and power - watts.
3. Inputs and outputs may be decimal numbers.
4. Test the code out on at least 3 different sets of inputs.
Laboratory Deliverables:
Submit hard copies of lab2a.c and lab2b.c along with outputs for all
test sets. Remember to include your name on all your work and use the
intro block.