My code:
I have tried multiple ways to fix this but to no avail.
I have to use scanf in the code so I cannot replace it with fgets as many people have told me to.
Can someone tell me what's wrong with my code?
#include <stdio.h>
float Parallel(float R1, float R2);
void main(void) {
char circ;
float R1, R2, R3;
printf("Select Circuit [A/B/X]: ");
scanf("%c", &circ);
if (circ == 'A') {
printf("Enter R1 and R2: ");
scanf("%f%f", &R1, &R2);
printf("%f%f", R1, R2);
Parallel(float R1, float R2);
printf("Total resistance for Circuit A is %.2f Ohm", RT);
}
if (circ == 'B') {
printf("Enter R1, R2 and R3: ");
scanf("%f%f%f", &R1, &R2, &R3);
Parallel(float R1, float R2);
RT = RT + R3;
printf("Total resistance for Circuit B is %.2f Ohm", RT);
}
if (circ == 'X') {
printf("That's All");
}
}
float Parallel(float R1, float R2);
{
float RT;
RT = 1 / (1 / R1 + 1 / R2);
return RT;
}