my code seems to not return any of the case statements other than default, when i enter in a number larger than zero... and im not sure why...
help please?
Code:#include <stdio.h>
int ResColour(int colour);
int main(void)
{
int input;
int rc;
int colour;
printf("Please enter a resistor value in ohms:\n");
rc = scanf("%d",&input);
if(rc!=1)
printf("Please enter a valid resistor value!\n");
else if(input==0)
printf("Please enter a valid resistor value!\n");
else if(input < 0)
printf("Please enter a valud resistor value!\n");
else if(input > 0)
{
printf("The colour code for resistor value %d is:\n",input);
ResColour(colour);
}
printf("\n\n");
return(0);
}
int ResColour(int colour)
{
switch(colour)
{
case 0: printf( " black");
break;
case 1: printf( " brown");
break;
case 2: printf( " red");
break;
case 3: printf( " orange");
break;
case 4: printf( " yellow");
break;
case 5: printf( " green");
break;
case 6: printf( " blue");
break;
case 7: printf( " violet");
break;
case 8: printf( " grey");
break;
case 9: printf( " white");
break;
default: printf( " unknown digit detected");
return(colour);
}
}