I have written a small program in C but I don't really understand why my program does not work. Here is my code:
But the generated output is not satisfactory. What and where is the problem? For example i need to print out the value of i, j and p[j+1]. and the iterations seem wrong. It suppose to come out like this:Code:#include <stdio.h> #include <math.h> void main(void) { FILE *outFile; float p[1000]; float lambda = 1.0e-3; float i; int j; int m = 2; outFile=fopen("myfile.txt","w"); for (i=0.1; i < 1.0; i+=0.1) { for (j=0; j<=1000; j++) { p[0]=1.0e-5; p[j+1]=p[j] + lambda * pow((p[j]),(m/2)) * pow(i,m); fprintf(outFile, "\n%lf\n",i,j,p[j+1]); } } fclose(outFile); }
(example answer only)
i j p[j+1]
0.1 1 1.0002e-5
0.1 2 1.0003e-4
.
.
0.2 1 1.0005e-4
.
.
.
1 1000 1.011e-2
One more thing: is it possible for me to draw this number into line chart/graph with the help of above program?
Bookmarks