I need help with random generation of circuit, i have no idea on how to write c++ program to generate random circuit.
The following specifications must met:
1) Total number of resistors in the circuit is between 3 and 8.
2) The circuit network layout is restricted only to the one which can be expressed by a circuit
formula.

This seems like a homework problem. What have you done so far? What have you tried? What have you learned in class that could relate to this? Where are you stuck? Do you have any code so far?

It’s currently seeming as if you are tasked write this complicated c++ program but you don’t know c++ at all. We will help you to figure it out, but we won’t just do your work for you from scratch.

commented: #include "Resistor.h" #include <cstdlib> void Resistor::setResistance(double r1) { r=r1; } double Resistor::getResistance() { return r; } v +0

That's a great assignment they gave you. However up till this point the classes and work should have been preparing you for this so you may have to revisit your prior classwork, books and research to fill in what you didn't retain (knowledge.)

I'm an electronics designer first and later as microprocessors came into the design learned how to code, first in assembly and then higher level languages so my view on this problem is that it is NOT a C++ issue yet.

So what is it?

The problem is first how would you do this yourself and put that into repeatable steps. In fact such a design does NOT have to create a good circuit every time since you can randomly create such then test if it meets the other criteria. Or you may have an epiphany on how to create a good circuit then every time.

For example you could code up SIX routines as you randomly pick a number from 3 to 8 that know in advance the circuit network. Since the number of resistors is random then this may be the simplest to design.

Finally since these are resistors the only real answer to "expressed by a circuit" is that any selection and connection is a circuit since a circuit can be open as in no current so unless the assignment has a requirement that the circuit carry current through all paths, then you have an easier time here. As many will tell you over the years, always read the requirements.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.