I've checked out all my teacher's online examples, and worked at this thing for a long time, and i cannot for the life of me figure out why my program stops and closes in the middle.
I took out the if statements to see if that was where the error was, but that didn't fix it.
The program compiles and runs, but after the third scanf it just closes down on me. Any help would be greatly appreciated.
Code:
#include <stdio.h>
float parallel_resis(float,float,float);
float series_resis(float,float,float);
main()
{
float tot_par,tot_ser,r1,r2,r3;
printf("Please input the values for resistance in ohms\n\n");
printf("Value for resistance 1:\n");
scanf("%f",&r1);
printf("Value for resistance 2:\n");
scanf("%f",&r2);
printf("Value for resistance 3:\n");
scanf("%f",&r3);
tot_par=parallel_resis(r1,r2,r3);
tot_ser=series_resis(r1,r2,r3);
printf("The equivalent resistance for values of %f, %f, and %f are:\n\n",r1,r2,r3);
printf("For series wiring: %.3f\n", tot_ser);
printf("For parallel wiring: %.3f\n", tot_par);
return 0;
}
float parallel_resis(float r1, float r2, float r3)
{
return (1/(1/r1 + 1/r2 + 1/r3));
}
float series_resis(float r1, float r2, float r3)
{
return r1 + r2 + r3;
}