but i need to understand it....please....i must to present it.....honestly i don't like this subject...but i must to take it....please help me....this time only
The program also should prompt an error message if the user enter an invalid colour code.
You might do do that by adding a while loop, so that lines 13 to 19 are repeated endlessly until a valid input is given. Print out the error message just after line 19.
i need to plus value of tolerance
Since the colours for the tolerance band are different, you might want to add another function to get that input from the user.
the user enter “Y” or “y”, the program will continue, otherwise enter “N”or “n” the program will stop
Perhaps add a while or do-while loop inside main(), so that lines 29 to 34 are repeated. Just after line 34, prompt the user to enter 'y' or 'n' and make the loop condition test that value.
FROM THIS CODING...I NEED TO USED TAKE VALUE OF TOLERANCE AND the user enter “Y” or “y”, the program will continue, otherwise enter “N”or “n” the program will stop....and syntax error.....
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <string.h>
printf ("Enter color of band# : " );
scanf ("%s", input);
for (int i=0; i<10; i++)
{
if (strcmp(input, colors[i]) == 0)
return i;
}
printf("press:\t1 to continue??\n\n \t2 to end??");
scanf("%d",&condition);
i=condition;
printf ("Invalid input\n");
return 0;
}
int main()
{ int band[3];
int value;
int i;
for (int i=0; i<3; i++)
band[i] = get_band(i);
value = band[0] * 10 + band[1];
value *= (double)pow(10.0, (double)band[2]);
printf ("The value of that resistor is %ld ohms\n", value);
system("pause");
return 0;
}