Help. Beginner Programmer
Code:
#include <stdio.h>
int main()
{
float Tarray[] = {0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 100, 120, 140, 160, 180, 230, 280, 380};
float Varray[] = {.21, .30, .37, .45, .49, .50, .49, .47, .45, .43, .37, .33, .29, .25, .19, .13, .08, .04};
float Vavg[17];
float Tperiod[17];
float Vcalc[17];
float Sum = 0;
float TavgV = 0;
int i;
for(i=0;i<18;i++){
Vavg[i] = (Varray[i] + Varray[i+1])/2;
}
for(i=0;i<18;i++){
Tperiod[i] = Tarray[i+1] - Tarray[i];
Vcalc[i] = Tperiod[i]*Vavg[i];
Sum += Vcalc[i];
}
TavgV = Sum/(Tarray[17] - Tarray[0]);
printf("The time averaged voltage is", TavgV);
return (0);
}
When I compile this code in Quincy 2005, I get "The time averaged voltage is" with calculated value for TavgV missing.
Can anyone spot the error?
Also: Side note. Does anyone know what the concept of "the worst possible values" means? I need to create/explain a program in C/Python demonstrating them