how to program...?

I have a problem i programming can you help me.?
< I want to make a program to solve for the value of the resistor, can anybody help me???
You mean the Ohm's Law (R = V / I) ?
not the ohm's law the resistor reader in electronics.
Provide more information; it is unlikely that someone is going to do research simply to figure out what you are asking about...
Multiple posts, same topic: http://www.cplusplus.com/forum/general/8328/

If I understand correctly, you want to create a program that calculates the value of a resistor from its colored stripes. You need to take the colors of the stripes as input and convert them to their corresponding numerical values. Below is a (poorly written) snippet that should give you somewhere to start. An array of strings contains each of the colors, and each color's position in the array corresponds to its numerical value.


1
2
3
4
5
6
7
8
9
10
11
12
	string color[] = {"black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "gray", "white"};
	string stripe; // the color of a stripe
	int value; // the numerical value corresponding to that color
	
	cin >> stripe;

	for(int i = 0; i<10; i++){
		if(stripe == color[i]){
			value = i;
			break;
		}
	}


Then, you need to use that information to calculate the total resistance, which will be
(10*<first stripe> + <second stripe>)* 10^<third stripe>.
Last edited on
Topic archived. No new replies allowed.