resistor colour band

Pages: 12
closed account (Nh79E3v7)
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
closed account (Nh79E3v7)
please help me to do a code about resistor colour using if eslse......another thing about tolerance i think it of myself....please
I laid out a plan of a way forward in this post:
http://www.cplusplus.com/forum/beginner/191817/#msg925102

I'll repeat the suggestion here:

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.

closed account (Nh79E3v7)
i don't understand about it....please....i can't think it.....tomorrow i must to present it....please help me...only on this time...i really need help
What is it you don't understand. Please explain.
Show your attempt at writing the code, then we'll find the problems and fix them.
closed account (Nh79E3v7)
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>

double colors(const char *colors[10],double);

int get_band (int n)
{ char input[10];
int i,condition;
const char *colors[10] = { "black", "brown", "red", "orange", "yellow",
"green", "blue", "violet", "grey", "white" };

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;
}
That code generates a number of warnings, all of which were fixed in the code I posted yesterday. It seems we are going backwards.


closed account (Nh79E3v7)
I DON'T UNDERSTAND....PLEASE DO A NEW CODE USING IF ELSE FOR ME...I CAN'T UNDERSTAND TO DO IT...AND I NEED TO STUDY IT...PLEASE
Please accept my apologies. I have to go now.
closed account (Nh79E3v7)
you expert in c++ code....but you can't help me in simple assignment...hmmmm
Topic archived. No new replies allowed.
Pages: 12