Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The present homework is concerned with making various calculations, using the me

ID: 1565974 • Letter: T

Question

The present homework is concerned with making various calculations, using the method of call by reference, for a circuit consisting of a battery driving resistors connected in aeries across it. The program is to do the following in the indicated sequence when it is executed: 1. Ask the user to type on the keyboard the value of the battery voltage V_n. 2. Ask the user to type on the keyboard the number n of resistors connected in series across the battery. 3. Ask the user to type on the keyboard the values of the n resistors expressed as a one-dimensional array with elements r [0], r [1], ..., r [n - 1] of type float. 4. Display on the console the inputted values of V_n, n and r [n]. 5. Compute and display on the console the value req of the equivalent resistance to the n resistances connected in series. 6. Compute and display on the console the current 1 in mA flowing through the circuit. 7. Compute and display on the console the voltage array V [n] where each element of the array V [n] represents the voltage in V across the corresponding element of the resistance array r [n]. 8. Compute and display on the console the power array P [n] where each element of the array P [n] represents the power dissipated in the corresponding clement of the resistance array r [n]. 9. Compute the power P_n supplied by the battery and the total power P_R, tau ut dissipated in the resistors. Is the law of power conservation satisfied? Use prototype functions called "series", 'current", "voltage", and "power". The inputting of the values of V_0, n, and r [n] is to be done within the main program. The computation and outputting of the value of req is to be done from within the "series" function. The computation and outputting of the value of current I is to be done from within the "current" function. The computation and outputting of the elements of the voltage array V [n] is to be done from within the "voltage" function. The computation and outputting of the elements of the power array P [n], the value of the total power dissipated in the resistors, and the power supplied by the battery P_a, is to be done from within the "power" function. Use the following placement sequencing of the various functions in the program: series rightarrow current main rightarrow voltage rightarrow power. In your sample computation, use the values n = 6, V_0 = 10 V, and r [6] = {2.5, 5.0, 7.50, 10.0, 15.0, 60.0}, with all resistors in k Ohm.

Explanation / Answer

float series(float *resistance,int n)
{
    float sum=0.0;
    int i;
    for (i=0;i<n;i++)
        sum=sum+resistance[i];
    printf (" total resistance in the circuit is %f. ",sum);
    return sum;
}

float current(float V,float req)
{
    float I=V/req;
    printf(" total current in the circuit is %f mA ",I/1000);
    return I;
}

float voltage (float *resistance,int n,float I)
{

    int i;
    float temp;

    for(i=0;i<n;i++)
    {
        temp=resistance[i]*I;

        printf(" voltage across %f ohms is %f volts",resistance[i],temp);
    }
    return 0;
}


float power (float *resistance,int n, float I)
{

    int i;
    for(i=0;i<n;i++)
        printf(" power dissipated across %f ohms is %f W. ",resistance[i],resistance[i]*I*I);

    return 0;
}
int main()
{
    float Vb;
    int n;
    float req;
    float I;
    printf(" please enter the battery voltage :    ");
    scanf("%f",&Vb);
    printf (" please enter number of resistors in series :   ");
    scanf("%d",&n);
    float resistance[n];
    int i;
    for (i=0;i<n;i++)
    {
        printf(" enter the value of %d resistor value : ",i+1);
        scanf("%f",&resistance[i]);

    }
req=series(resistance,n);
I=current(Vb,req);

voltage(resistance,n,I);

power(resistance,n,I);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote