Not sure what the problem is here, but I keep getting the result of 0. The expected result is 0.2222222. I figure I must be assigning a zero to one of my variables but I can’t figure out where this is happening. Any help would be appreciated. Thanks
#include <stdio.h>
#include <math.h>
int main()
{
double vs = 10;
double rs = 100;
double rl_start = 50;
double rl_stop = 150;
double rl_step = 5;
double i, j;
double n = rl_start;
int count;
do
{
j = ((rl_start) + (rl_step * count));
i = (pow(vs, 2) * j) / pow((rs + j),2);
printf("%lf", i);
count++;
}while(j <= rl_stop);
return 0;
}
You need to initialize
countbefore using it:int count = 0;