#include <stdafx.h>
#include <stdio.h>
#include <string.h>
#define STRING 8
#define error -1
int
main(void)
{
char COLOR_CODES[10][8] = {"black", "brown", "red",
"orange", "yellow", "green", "blue", "violet", "gray",
"white"};
char color1[STRING],
color2[STRING],
color3[STRING];
int i, counter, a, b, c;
counter = 0;
printf("How many resistors do you want to decode? => ");
scanf("%d", counter);
for (counter = 0;
counter < i;
counter += 1){
printf("Enter the colors of the resistor's three bands, beginning with\nthe band nearest the end. Type the colors in lowercase letters\nonly, NO CAPS.\nBand 1 => ");
scanf("%s", color1);
printf("\nBand 2 => ");
scanf("%s", color2);
printf("\nBand 3 => ");
scanf("%s", color3);
int a;
if (strcmp(color1, "black") == 0) {
a = 0;
} else if (strcmp(color1, "brown") == 0) {
a = 1;
} else if (strcmp(color1, "red") == 0) {
a = 2;
} else if (strcmp(color1, "orange") == 0) {
a = 3;
} else if (strcmp(color1, "yellow") == 0) {
a = 4;
} else if (strcmp(color1, "green") == 0) {
a = 5;
} else if (strcmp(color1, "blue") == 0) {
a = 6;
} else if (strcmp(color1, "violet") == 0) {
a = 7;
} else if (strcmp(color1, "gray") == 0) {
a = 8;
} else if (strcmp(color1, "white") == 0) {
a = 9;
}
int b;
if (strcmp(color2, "black") == 0) {
b = 0;
} else if (strcmp(color2, "brown") == 0) {
b = 1;
} else if (strcmp(color2, "red") == 0) {
b = 2;
} else if (strcmp(color2, "orange") == 0) {
b = 3;
} else if (strcmp(color2, "yellow") == 0) {
b = 4;
} else if (strcmp(color2, "green") == 0) {
b = 5;
} else if (strcmp(color2, "blue") == 0) {
b = 6;
} else if (strcmp(color2, "violet") == 0) {
b = 7;
} else if (strcmp(color2, "gray") == 0) {
b = 8;
} else if (strcmp(color2, "white") == 0) {
b = 9;
}
int c;
if (strcmp(color3, "black") == 0) {
c = 0;
} else if (strcmp(color3, "brown") == 0) {
c = 1;
} else if (strcmp(color3, "red") == 0) {
c = 2;
} else if (strcmp(color3, "orange") == 0) {
c = 3;
} else if (strcmp(color3, "yellow") == 0) {
c = 4;
} else if (strcmp(color3, "green") == 0) {
c = 5;
} else if (strcmp(color3, "blue") == 0) {
c = 6;
} else if (strcmp(color3, "violet") == 0) {
c = 7;
} else if (strcmp(color3, "gray") == 0) {
c = 8;
} else if (strcmp(color3, "white") == 0) {
c = 9;
}
}
printf("\nResistance value: %d%dx10^%d ohms\n", a, b, c);
return (0);
}