somebody can help me to write a C++ sourcecode for me
The question ask to calculate the total resistance in a circuit involve parallel and series connections of resistors..In that the program firstly we need to insert the number of resistors and the value of resistance for each resistor.Then the input the number and the resistance value should show in array form..
So hopefully anyone can help me to solve my problem..Thank you ^.^
this is a part sourcecode of that i hav done..but still not correct..
#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.\n";
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();
}
From your given requirements, it looks like you should ask whether to calculate resistance for a series circuit or a parallel circuit.
I do not know what you mean by "the resistance value should show in array form". The total resistance is a single number. Does the professor mean that you should calculate equivalent resistance for both series and parallel, and display both results?
1 2 3 4 5 6 7 8
Enter the number of resistors in the circuit: 3
Enter the value of resistance below.
R1:5500
R2:22000
R3:500
The value of equivalent resistance is:
In Parallel In Series
449 28000
It does not seem to me that you really understand the problem.
What are the assumptions about the layout of the circuit? Not "something like this", but "exactly like this: with n of these and m of these and k of this"
Try doing it by hand. Using algebra.
Then try to write your program again.
@Duoas: hooray for color codes! spiffy tutorials too.