What a great site! I'm looking fo a hint. I'm new to any type of programming and this C code just doesn't seem to be working.
I have attempted a program that gives the ohm value of a resistor when the color code is entered in. I am using an "enum" data type to assign a number value to each color code. The program will run but after I enter the first code, it jumps to the end and displays a nonsense answer. I'm just looking for a hint. I'm sure my mistake is obvios, just not to me. Any help will be great.
//#include <stdio.h>
#include <math.h>
#include<stdlib.h>
typedef enum {black, brown, red, orange, yellow, green, blue, violet, gray, white} color_code_t;
int main()
{
int x;
int y;
double z;
double res_value = 0;
printf("...more explanation goes here, later...\n\n\n");
printf("black is %d\n", black);
printf("brown is %d\n", brown);
printf("red is %d\n", red);
printf("orange is %d\n", orange);
printf("yelllow is %d\n", yellow);
printf("greeen is %d\n", gray);
printf("blue is %d\n", blue);
printf("violet is %d\n", violet);
printf("gray is %d\n", gray);
printf("white is %d\n", white);
/*get input, one color at a time*/
printf("\t\t What color is the first band?\n=>");
scanf("%d", &x);
printf("\t\t What color is the second band?\n =>");
scanf("%d", &y);
printf("\t\t What color is the third band?\n=>");
scanf("%lf", &z);
/*the math*/
res_value = ((x * 10) + y) * pow(10,z);
printf("\t\t The resistor value is %f ohms.\n", res_value);
return 0;
}