Write a C++ program that calculates the series and parallel resistance for a gro
ID: 673058 • Letter: W
Question
Write a C++ program that calculates the series and parallel resistance for a group of resister values. Your program will read in from the data file the number of resistors and then the values for those resistors. It will then calculate the equivalent series and parallel resistance values. For example, 3 resistors with the values of 100, 200 and 300 would yield the equivalent series resistance of 100+200+300 and their equivalent parallel resistance... the data file is just one column that has the number of resistors followed by the value for each resistor. keep going until 0 is read. and the output should read the number of resistors, values of them, then the parallel and series resistance. use 2 loops.
4
100
150
300
600
3
150
200
120
0
Explanation / Answer
#include <iostream.h>
#include <conio.h>
void main()
{
double *res,total =0.0;
int n, c;
cout << "Enter the number of resistor in the circuit: ";
cin >> n;
res = new double[n+1];
cout << "Enter the value of resistance below. ";
for (c = 1; c <= n; c++)
{
cout << "R"<<c<<":";
cin >>res[c];
}
for (c=n;c>2;c-=2)
{
res[c-2] =(res[c]+res[c-1])*res[c-2]/(res[c]+res[c-1]+res[c-2]);
}
total=res[1]+res[2];
cout<<"The value of equivalent resistance is :"<<total<<endl;
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.