toku1991
New Coder
Hey people,
i was playing around with my first c program and i have a strange thing happening
when output is 0.001 the value is 1000 nOhm but it should be 100mOhm
i was playing around with my first c program and i have a strange thing happening
when output is 0.001 the value is 1000 nOhm but it should be 100mOhm
C:
// calculate resistance and print out how much omh it is
case 1:
printf("what is your Voltage?\n");
scanf("%Lf", &volt);
printf("what is your Amperage?\n");
scanf("%Lf", &ere);
output = volt / ampere;
if (output >= 0.0000000001 && output < 0.000001) {
printf("%0.0Lf %s\n", output * 1e6, "nOhm"); // Convert to nano
printf("%0.9Lf %s\n", output, "Ohm"); // Display as is
}
if (output >= 0.000001 && output < 0.001) {
printf("%0.0Lf %s\n", output * 1e6, "uOhm"); // Convert to micro
printf("%0.9Lf %s\n", output, "Ohm"); // Display as is
}
if (output >= 0.001 && output < 1 ) {
printf("%0.0Lf %s\n", output * 1e3, "mOhm"); // Convert to mili
printf("%0.9Lf %s\n", output, "Ohm"); // Display as is
}
if (output > 1) {
printf("%0.0Lf Ohm\n", output);
}
break;