calculate total resistance value

Oct 14, 2009 at 5:24pm
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();
}
Last edited on Oct 14, 2009 at 5:49pm
Oct 14, 2009 at 5:31pm
If you'll show what code you've started with, I'm sure someone would be happy to guide you from there.

We're coders, not homework-doers. :D
Oct 14, 2009 at 8:34pm
http://www.radioing.com/hamradio/resistors.html
;-]

Seriously now:

Your code does not account for the difference between parallel and series circuits (nor, as far as I can tell, does it do anything but mangle numbers).
http://www.wisc-online.com/objects/index_tj.asp?objID=DCE1502
http://www.wisc-online.com/objects/index_tj.asp?objID=DCE2702

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

Hope this helps.
Oct 15, 2009 at 10:04am
that's almost like the way that i want..but i meant to calculate the equivalent resistance in a circuit that have both parallel and series connection.

The circuit something like this..so i need to calculate the total resistance in the circuit.

___###_____..........._____####_______###___
| | | |
| | | |
# # # #
# # # #
| | | |
| | | |
|-------------|----............--|---------------|-------------------

hopefully some one can guide me..Thanx a lot
Last edited on Oct 15, 2009 at 10:07am
Oct 16, 2009 at 1:43am
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.
Topic archived. No new replies allowed.