1.Store the resistor colors in an array
2.Ask the user to enter three colors
3.Use a loop to find their colors in the array and convert them to their number equivalents
4.Calculate and print out the resistance value for the colors they entered
This is my homework. I can't figure out how to do it. I stored the colors in an array and asked the user to enter three colors,but i can't figure how to convert them to their number equivalent and calculate them use the formula R = (10 a+b) *10c. The code looks repetitive because we haven't learn the function. I am not expecting an answer but some hint and advise. Thank you.
The empty statement enclosed in braces probably looks strange. They are there to make it really REALLY clear that there is nothing happening in the loop. Coding it like this: for (c1=0; c1 < 10 && color1 != colors[c1]; ++c1);
is functionally the same but it's way too easy for a person to miss the semicolon and get confused.