Question

The program has to be written in C

OPTIONAL TAKE-HOME QUIZ WORTH 10 POINTS OUT OF A GRAND TOTAL OF 110 FOR THE COURSE A DC electrical circuit consists of an ideal battery with user-suppled terminal voltage VB which drives a resistive load comprised of a user-supplied number m of branches connected in parallel across each other, with each branch consisting of a variable user-supplied number n of resistors and user-supplied values of the resistors. NOTE: the number of resistors in a branch and their values, which are user supplied, vary in general from branch to branch. of call by reference which, when Design a program using either the method of call by value or the method run, will do the following in the indicated sequence: Ask the user to type on the keyboard the value of the battery voltage VB Ask the user to type on the keyboard the value of the number m of the resistive branches connected in parallel. Ask the user to type on the keyboard the number n of resistors in branch O followed by the values of these resistances expressed as a one-dimensional array. The program will then, using a prototype function called series, compute the equivalent resistance to all.of the resistors connected in series in branch 0 Ask the user to repeat step 3 for branch 1, then branch 2, and so on until the last branch m-1 is reached Having reduced each branch of resistors to a single equivalent resistance, the program will next compute the equivalent resistance req to the m parallel-connected single resistances computed in steps 3 and 4 using a prototype function called parallel The program will, using a prototype function called SumentaNpowe supplied by the battery, a one-dimensional array whose elements are the currents Io, I, I-i in the m branches, and a one-dimensional array whose elements are the powers dissipated in the m resistive branche:s The program will finally compute the power supplied by the battery to the resistive load. 1. 2. 3. 4. 5. 6. next compute the power PB 7. NOTE: For sample output, use the following values for the circuit elements: m-3 (three resistor branches) For the m-0 branch, n-4, with r10-10.0, r[1]-20.0, r[2]-30.0 and r[3]#40.0 For the m-1 branch, n-3, with rfo]-50.0, r[1]-40.0, r[2-10.0 For the m-2 branch, n-2, with o]-20.0 and 1]-30.0 Vo=10V All resistor values in ohms The output screen on the console corresponding to the above inputted quantities is attached for your convenience

The expected output:

Please make sure to use two-dimensional arrays.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <stdio.h>
int main(int argc, char const *argv[])
{
int branch,resistor;
double VB, r[50][50], req[50]={0}, total_eq=0,eq;
printf("Please enter value for battery voltage VB in volts: ");
scanf("%lf",&VB);
printf("Please enter value for number m of branches: ");
scanf("%d",&branch);
printf("\n");
for (int i = 0; i < branch; ++i)
{
printf("Please enter the number of resistors n in brach %d : ", i);
scanf("%d",&resistor);
for (int j = 0; j < resistor ; ++j)
{
printf("Please enter a value of resistor r[%d][%d] in ohms: ",i,j);
scanf("%lf", &(r[i][j]));
req[i]+=r[i][j];
printf("Equivalent resistance #%d in branch #%d is r[%d] = ", i,j,j);
printf("%lf ohms \n", r[i][j]);
}
printf("Result: Equiv. resistance to resistors in brach #%d is =%f ohms \n \n", i, req[i]);
total_eq+=req[i];
}
eq=total_eq/VB;
printf("\n Equiv. resistance seen by battery req= %lf ohms \n", eq);
printf("Current & power supplied by battery are: IB = %lf A, PB= %lf W\n", VB/eq , (VB/eq)*VB);
for (int i = 0; i < branch; ++i)
printf("Current in and power dissipated in branch %d are I[%d]=%lf A, P[%d]= %lf W \n", i, i, VB/req[i], (VB/req[i])*VB);
return 0;
}

Output:

dps@machine:~/Downloads$ gcc main.c-o kewl dps@machine:~/Downloads$./kewl Please enter value for battery voltage VB in volts:

Add a comment
Know the answer?
Add Answer to:
The program has to be written in C The expected output: Please make sure to use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The present quiz is concerned with making calculations on the circuit shown below which consists of:...

    The present quiz is concerned with making calculations on the circuit shown below which consists of: an ideal battery with user-supplied terminal voltage V_0: and a user-supplied number m of branches of resistors which are connected in series within each branch, with these branches connected in parallel across each other, and with each branch consisting of a variable user-supplied number n of resistors and user-supplied values of the resistors. Design two programs in C, one using the method of call...

  • Please use MATLAB to solve this, thanks 7. Write a function M-file that will compute the...

    Please use MATLAB to solve this, thanks 7. Write a function M-file that will compute the equivalent resistance for a series or parallel combination of an arbitrary number of resistors. Your function should: accept as input an arbitrary number of resistor values, stored in a vector ask the user to input 'p' if the resistors are in parallel; ask the user to input 's' if the resistors are in series; output the equivalent resistance for the series or parallel combination...

  • Task 1 The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in series is g...

    Use MATLAB to solve these problems, thank u Task 1 The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in series is given as eq.series R1 R2 R3 R4. The equivalent resistance Req of four resistors R1, R2, R3 and R4 connected in parallel is given as q.parallel K1R2R3 R Write an m-file that does the following in order: Prompt the user for the type of connection (e.g. user should enter "1" for series and "2"...

  • *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create...

    *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create an array of doubles named “hummus” with 2 rows and 300 columns. Initialize all array elements to zero. Write a loop that will repeatedly ask the user to enter a value and store it in the first row of the array (do not overwrite previously entered values) until the whole first row is populated with the user input. (hint the loop should have the...

  • Problem: Create a program that will ask scientist in tracking the resistances of products from various...

    Problem: Create a program that will ask scientist in tracking the resistances of products from various batches. The resistances of good resistors should be between 3 and 3.5 inclusive. Your program will need to track the number of resistances that are too high (>3.5 ohms), the number of resistances that are too low (<3.0ohms) and calculate the average of the resistances that fall in the proper range (>=3 and <= 3.5). Your program should prompt the user to enter name...

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • Motes Ask Your Teacher 10. 0/12 points| Previous Ansiwers PSEB 2B.AF.a4 Active Figure 28.4 Resist...

    Motes Ask Your Teacher 10. 0/12 points| Previous Ansiwers PSEB 2B.AF.a4 Active Figure 28.4 Resistors Connected in Series The animation below shows a circuit diagram for two resistors connected in series acrass a battery Instructions Use the sliders to adjust the resistances and battery voltage and observe the effect on the current and voltages across each resistor. Explore In the animation, the two resistors are connected directly to the battery, so they both share a portion of the battery voltage...

  • In C++ 1. Write a program that allows a user to enter 10 integer values from...

    In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...

  • use C++ to write the following program. needs to ask the user for n The user...

    use C++ to write the following program. needs to ask the user for n The user must put in those 5 values, probably using a for loop. NOTE: You can assume the number of values to be entered is 5. My attempted program below: (not correct, but just a basis) 4. Larger Than n In a program, write a function that accepts three arguments: an array, the size of the array, and a number n. Assume that the array contains...

  • Pease answer questions 4 and 5! Thank you so much! 4. Connect the 2nd resistor in...

    Pease answer questions 4 and 5! Thank you so much! 4. Connect the 2nd resistor in parallel with the 1st resistor and connect that combination to the battery.          Measure the following:               The current passing through the R1, I1 = ___0.0058____ A               The current passing through the R2, I2 = ___0.0031____ A               The current supplied by the battery, I = ___0.0092____ A              Calculate I1 + I2 = ____________ A                     Is the following statement true? I = I1 +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT