# Thread: Hi need some help

1. ## Hi need some help

Hi first time posting. Very new to C coding, currently doing the basics for college. The program is a decimal to rad/degrees to Fahrenheit converter. We had to add to the code to get resistors in series to add together. Just having trouble getting the last bit to work. Any help would be great. Its the last part of the code option 3 im having trouble with.
Code:
```#include <stdio.h>
#include <stdlib.h>

int main() {
int Option, ResCount , Resistors, ResValue, ResTotal;
ResCount = 0;
printf("\t\t_____________________\t\t");
printf("\n\n\tl. Temperature conversion\n");
printf("\t2. Angle conversion\n");
printf("\t3. Series Resistance");
printf("\n\t\nPlease select one of the above options: ");
scanf("%i", & Option);

if (Option == 1) {
float c, f;
do {
printf("Enter Temp between -40 and 60: ");
scanf("%f", & c);

if (c < -40 || c > 60) {
printf("\n\n\t Wrong Value");

}
} while (c < 0 || c > 100);
f = c * 9.0 / 5.0 + 32.0;
printf("Fahrenheit is %.2f", f);

} else if (Option == 2) {
float d, r;
printf("Enter Degrees: ");
scanf("%f", & d);
r = d * 3.14 / 180.0;
}

else if (Option == 3) {
printf("\n\t\tSeries Resistance\n");
printf("\t\t___________________\n");

printf ("\n\tHow many resisitors do you have?(2-9):\t");
scanf  ("%i", &Resistors);
if (Resistors < 2 || Resistors > 9){
printf ("\tEnter a value between 2 and 9\n");
}
while (Resistors <2 || Resistors >9);
for (ResCount=0; ResCount < Resistors; ResCount++){
printf ("\tPlease enter R%i value (Ohms): ", ResCount+1);
scanf("%i", ResValue);
ResTotal = ResTotal + ResValue;
}
printf ("\n\tTotal Resistance is %i Ohms", ResTotal);
}

return 0;
}``` 2. 1, indentation really helps to see what's going on.
Code:
```#include <stdio.h>
#include <stdlib.h>

int main()
{
int Option, ResCount, Resistors, ResValue, ResTotal;
ResCount = 0;
printf("\t\t_____________________\t\t");
printf("\n\n\tl. Temperature conversion\n");
printf("\t2. Angle conversion\n");
printf("\t3. Series Resistance");
printf("\n\t\nPlease select one of the above options: ");
scanf("%i", &Option);

if (Option == 1) {
float c, f;
do {
printf("Enter Temp between -40 and 60: ");
scanf("%f", &c);
if (c < -40 || c > 60) {
printf("\n\n\t Wrong Value");
}
} while (c < 0 || c > 100);
f = c * 9.0 / 5.0 + 32.0;
printf("Fahrenheit is %.2f", f);
} else if (Option == 2) {
float d, r;
printf("Enter Degrees: ");
scanf("%f", &d);
r = d * 3.14 / 180.0;
}
else if (Option == 3) {
printf("\n\t\tSeries Resistance\n");
printf("\t\t___________________\n");
printf("\n\tHow many resisitors do you have?(2-9):\t");
scanf("%i", &Resistors);

if (Resistors < 2 || Resistors > 9) {
printf("\tEnter a value between 2 and 9\n");
}
while (Resistors < 2 || Resistors > 9);

for (ResCount = 0; ResCount < Resistors; ResCount++) {
printf("\tPlease enter R%i value (Ohms): ", ResCount + 1);
scanf("%i", ResValue);
ResTotal = ResTotal + ResValue;
}
printf("\n\tTotal Resistance is %i Ohms", ResTotal);
}
return 0;
}```
2, compile with lots of warnings enabled.
Code:
```\$ gcc -Wall -Wextra foo.c
foo.c: In function ‘main’:
foo.c:46:13: warning: format ‘%i’ expects argument of type ‘int *’, but argument 2 has type ‘int’ [-Wformat=]
scanf("%i", ResValue);
^
foo.c:46:7: warning: ‘ResValue’ may be used uninitialized in this function [-Wmaybe-uninitialized]
scanf("%i", ResValue);
^```
In this case, you forgot an & on one of your scanf's. 3. Thanks for the reply. How do i set the compiler to have more warnings? 4. Well which compiler / IDE are you using? 5. Im using GNU compiler 6. So am I.
So you've already seen how I use gcc.
Now you can do the same. Popular pages Recent additions add, bit, code, resistors, trouble 