Question: Write a C program that prompts for the colors of Band 1, Band 2, Band 3 and Band 4, and then displays the resistance in

Write a C program that prompts for the colors of Band 1, Band 2, Band 3 and Band 4, and then displays the resistance in ohms and the tolerance. Here is a sample run of the C program:

the resistor and tollerance storage is shown as follows
#include struct resist_value { char COL[10]; // COLOR_CODES_TOL for resistor band colours int VAL; // VAL for resistor band values (for bands one to three) float TOL; // TOL for resistor tolerance (for band four) }; // The colour bands, band values and tolerances are defined in the array COLOR[10] struct resist_value RESIST[NUM_COL]={{"black" ,0 ,-1}, // '-1' means no tolerance is illustrated for the colour { "brown" ,1 ,1}, { "red" ,2 ,2}, { "orange",3 ,-1}, // '-1' means no tolerance is illustrated for the colour { "yellow",4 ,-1}, // '-1' means no tolerance is illustrated for the colour { "green" ,5 ,0.5}, { "blue" ,6 ,0.25}, { "violet",7 ,0.1}, { "grey" ,8 ,-1}, // '-1' means no tolerance is illustrated for the colour { "white" ,9 ,-1}, // '-1' means no tolerance is illustrated for the colour { "Gold" ,-1 ,5}, // '-1' means no tolerance is illustrated for the colour { "Silver" ,-1 ,10}, // '-1' means no tolerance is illustrated for the colour { "None" ,-1 ,20} // "" and -1 means no colour band; };
NOTE: the tollerance must be included in the output, and the Coloured bands must be defined as shown
A resistor is an electric circuit device component and it has a specific resistance value, where the resistance values are expressed in ohms (S). Resistons are generally marked with four colored bands that encode their resistance values which are shown in the following figure. First digit Second digit Multiplier olerance (Band one) (Band two) (Band three) (Band fou The first two bands (Band one and Band two) are the first and the second digits. The third band (Band three) is a power-of-ten multiplier. The fourth band (Band four) indicates the tolerance of the resistor which is the percentage deviation of the desired resistance value, measured at 25C The table below shows the meanings of each band color. For example, if the first band is green, the second is black, the third is orange and the fourth is red, the resistor has a value of 50x102 with a tolerance of 2%. Color Value as digit Value as multiplier Tolerance (Bands one and two) (Band three) (Band four) Orange 10 10 Silver 10 No color 200
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
