Please can anyone help me with the following :
http://www.staff.ncl.ac.uk/alex.yako...se/ladder.html
It has to work in Cygwin Bash Shell
Thanks !
Please can anyone help me with the following :
http://www.staff.ncl.ac.uk/alex.yako...se/ladder.html
It has to work in Cygwin Bash Shell
Thanks !
Last edited by TaBkill3r; 11-09-2007 at 03:45 AM.
So what bit are you stuck on?
- parsing the input data
- doing the calculations
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I can't finish part 1
-doing the calculations
So post your best effort to date, and ask a more specific question about something you're stuck on, or what to do next.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I have done this so far ( input the readings)...
---------------------------------------------------------------
----------------------------------------------------------Code:int main() { const int MAXSIZE=10; // absolute max size of the array double readings[MAXSIZE]; // array declaration int noOfRes; // actual number of readings int carryon = 1; // initialise flag to continue calculations while (carryon) { cout << "Enter actual number of the resistors. (0<n<=" << MAXSIZE << "): "; cin >> noOfRes; cout << endl; // enter actual readings from keyboard cout << "Enter the actual value of the resistors (Ohms) , one at a time, following the prompt\n"; for (int i = 0; i < noOfRes; i++) { cout << "reading(" << i+1 << ") = "; cin >> readings[i]; } cout << endl;
How i will do that ?
Calculate the overall equivalent resistance of the circuit
Last edited by TaBkill3r; 11-09-2007 at 07:21 AM.
Why are you asking for temperarures, when the link you posted is referring to a resistor ladder?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
So, what about actually TRYING to write some calculations? After all, the formulas are defined in the project specification.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Mate im not good as you in C++, i can't find how i'll make the programm distinguish between odd and even numbers. I think i'll use if the number
of the resistor is %2=0 then do the calculations which are specified in the problem.
I want you to write me the code for that if you can ....
And I don't want to do that, because it would teach you absolutely nothing [and teach me barely anything, because although I haven't implemented this type of calcuation, I don't think it's particularly hard]. So why should I?
You have the right idea of "how to check if a number is odd or not". x % 2 will be either 0 (x is even) or 1 (x is odd).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
You really don't need to worry about odd/even. To solve this type of circuit you just have to work backwards.
The last two resistors are in series. That equivalent resistor is in parallel with the next resistor. That equivalent resistor is in series with the next resistor. That equivalent resistor is in parallel with the next resistor. Repeat until you have no more resistors.
For this problem you know the last two resistors are in series and that there are 2n resistors.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I think an easier way to deal with something like this is to calculate the currents in each loop. (by applying kcl and kvl laws, and a method called the "maas" currents... I'm sure there is a formal english word for this).
Aferwards you get for instance 5 equations with 5 unknown variables, put it in a matrix form, calculate the echelon form of this matrix.
And kabang there you have all the currents in each loop, then its just a matter of calculating the voltage which is easy since you know all currents and know all resistance values...
I think programming wise, its easier to do it this way, the only difficult part is finding the loops and all nodes and know which resistor is in which loop...afterwards its just applying some simple laws and mathematics.
I bet if you work it out like this you get even better grades!
Last edited by GanglyLamb; 11-09-2007 at 12:09 PM.
This is an easy task.
For all series-parallel circuits do the parallel portion first. This effectively turns the parallel portion into a series portion or turns many resistors into one with a corresponding resistance value.
Once you have this then you can plug the values into Ohm's law and figure out the rest of the circuit.
Parallel: Total = 1/R1 + 1/R2 + 1/R3 + .... 1/Rn
Series: Total = R1 + R2 + R3 + ... + Rn
Ohm's law: E = IR - E = voltage, I = amperage, R = resistance
I highly recommend RIEP charts (P(ower)=I * E) to figure circuits out. You can implement this in code as well. Using RIEP charts you can figure out any circuit with little trouble.
Most of that question is a 'trick' question. Regardless of how the resistors in a circuit are arranged they always follow the fundamental parallel or series rules. If you have parallel portions, you must figure those out first.
Also remember this:
Series
Amperage is constant - hence you get voltage drops across the resistors
Parallel
Voltage is constant - hence you can figure out how many amps are flowing through each resistor in a parallel circuit
Last edited by VirtualAce; 11-09-2007 at 05:00 PM.