#include<stdio.h>
#include<math.h>

void getColorCode(char colorCode[]);
long getResistorValue(char colorCode[]);


int i,ch;
long r_value=0;
char ans;
char j;
char code;
char colorCode[3];
int colorValue[3];
int main (void) {

/* clrscr();
printf("\n\t\t\t\tRESISTANCE CALCULATOR");
printf("\n\t\t\t\t");
for(i=1;i<11;i++)
{
delay(10000);
printf("*");
}*/

printf("\n1. START");
printf("\n2. QUIT");
printf("\nEnter your Choice(1-2):");
scanf("%d",&ch);
    clrscr();
switch(ch)
{
case 1:
printf("*****************************************************\n\n");
printf(" This program will calculate the value of a resistor.\n\n");
printf("*****************************************************\n\n");
printf("****************************");
printf("* B = Black\nN = Brown\nR = Red\nO = Orange\nY = Yellow\n *");
printf("* G = Green\nL = Blue\nV = Violet\nE = Gray\nW = White\n\n *");
printf("****************************");
printf ("Enter the 4-character color description of the resitor:");
getColorCode(colorCode);

r_value=getResistorValue(colorCode);
printf("\n\nThe resistor with band color %c %c %c has a value of %d Ohms.\n", colorCode[0], colorCode[1], colorCode[2], r_value);
printf("Would you like to enter another resistor? y(yes) or n(no)");
scanf("%c", &code);
switch (code){
case('y'):insert();
break;

case('n'): print();
return 0;
default: printf("Invalid entry. Try Agin.\n");
return 0;
}
}
void getColorCode(char colorCode[]) {
int i;
for(i=0;i<=4;i++)
colorCode[i]=getchar();
}
long getResistorValue(char colorCode[]){

int i;
double multiplier;
char band_color;
long value;
int colorValue[3];

for(i=0;i<3;i++) {
band_color = toupper(colorCode[i]);

switch (band_color) {
case('b'):
case('B'):
colorValue[i] = 0;
break;

case('n'):
case('N'):
colorValue[i] = 1;
break;

case('r'):
case('R'):
colorValue[i] = 2;
break;

case('o'):
case('O'):
colorValue[i] = 3;
break;

case('y'):
case('Y'):
colorValue[i] = 4;
break;

case('g'):
case('G'):
colorValue[i] = 5;
break;

case('l'):
case('L'):
colorValue[i] = 6;
break;

case('v'):
case('V'):
colorValue[i] = 7;
break;

case('e'):
case('E'):
colorValue[i] = 8;
break;

case('w'):
case('W'):
colorValue[i] = 9;
break;
default:
printf("\nERROR: Color Code %c is not a valid choice\n", colorCode[i]);
break;
}
}
multiplier = pow(10, (double) colorValue[2]);
value = (((colorValue[0]*10) + colorValue[1] * multiplier);
return value;
}


case 2:
{
system("cls");
gotoxy(16,3);
printf("Programmers....");
gotoxy(16,4);
printf("1. Cabaltican Marx Lennin");
gotoxy(16,5);
printf(" Mobile: E-mail:");
gotoxy(16,7);
printf("2. Manalo Maria Cristina");
gotoxy(16,8);
printf(" Mobile: E-mail:");
gotoxy(16,10);
printf("3. Punzalan Roujen Rizell");
gotoxy(16,11);
printf(" Mobile: E-mail:");
gotoxy(16,13);
printf("Exiting in 3 second...........>");
//flushall();
Sleep(3000);
exit(0);
}
default:


return r_value;
}

Recommended Answers

All 4 Replies

error at line 58 void getColorCode(char colorCode[]) {

Expresssion syntax in function main

can you please help me with this..

can you please help me with this..

Sure we can, don't get your knickers in a twist!

The best help you can get is format your code. Most likely your problem will become immediately apparent.

Without better formatted code I can only guess the problem is mismatched { and }.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.