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: 3827086 • 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 series across it. The program is to do the following in the indicated sequence when it is executed: Ask the user to type on the keyboard the value of the battery voltage V_B. Ask the user to type on the keyboard the number n of resistors connected in series across the battery. 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. Display on the console the inputted values of V_B, n and r [n]. Compute and display on the console the value req of the equivalent resistance to the n resistances connected in series. Compute and display on the console the current I in mA flowing through the circuit. 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]. 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 element of the resistance array r [n]. Compute the power P_B supplied by the battery and the total power P_R, Tot 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 Vo, n, and r [n] is to be done within the main program. The computation and outputting of the value of 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 P_R, Tot dissipated in the resistors, and the power supplied by the battery P_B, is to be done from within the "power" function. Use the following placement sequencing of the various functions in the program: series rightarrow current rightarrow main rightarrow voltage rightarrow power. In your sample computation, use the values n = 6, Vo = 10V, and r [6]={2.5, 5.0, 7.50, 10.0, 15.0, 60.0}, with all resistors in k Ohm.

Explanation / Answer

#include<iostream>
#include<cmath>
using namespace std;

double req;
double Vb;
double I;

void series(double a[],int &size)
{


   for (int i = 0; i < size; i++)
   {
       req = req + (1 / a[i]);
   }

   req = 1 / req;
   cout<<" req: "<< req;
}

void current()
{
   cout << " I: "<<Vb/req << req;

}

void voltage(double a[], int &size)
{
   cout << " v[n] ";

   for (int i = 0; i < size; i++)
   {

       cout << a[i] * I<<" ";
   }
}

void power(double a[], int &size)
{
   cout << " Pb: " << pow(Vb, 2)*I;

   double Prtot;
   cout << " p[n] ";
   for (int i = 0; i < size; i++)
   {
       cout<< a[i] * pow(I, 2);
       Prtot = Prtot+a[i] * pow(I, 2);
   }

   cout << Prtot;
}
int main()
{
   int size;
   double *r;
   cout << "enter vb :";
   cin >> Vb;
   cout << " enter num of resistors :";
   cin >> size;

   cout << " enter elemnts on a line :";
       r = new double[size];
       for (int i = 0; i < size; i++)
       {
          
           cin >> r[i];
      
       }


       series(r, size);
       current( );
       voltage(r, size);
       power(r, size);
       system("pause");
}

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