THERE ARE TWO PROGRAMS THAT NEED TO BE DONE IN THIS QUESTION. NEED DONE IN C PRO
ID: 3839186 • Letter: T
Question
THERE ARE TWO PROGRAMS THAT NEED TO BE DONE IN THIS QUESTION. NEED DONE IN C PROGRAMMING
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_alpha 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 by value and the other using the method of call by reference, which will perform the following computations: the equivalent resistance R_eq seen by the battery, and the one-dimensional array whose elements are the currents I_o, I_1, ..., I_m-1 in the m branches.Explanation / Answer
prgoram 1
#include<stdio.h>
int main()
{
int n; /* number of resistors */
float er; /* equivalent resistance */
int r2;
int i; /* loop variable */
float temp;
printf("enter number of resistors ");
scanf("%d",&n);
printf("enter all resistances ");
scanf("%f",&er);
for(i=1;i<n;i++)
{
scanf("%d",&r2);
temp=(1/er)+((1/(float)r2)); /* cast r2 to float */
er=(1/temp);
}
printf(" equivalent resistance = %f",er);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.