| Thread Closed |
functions in c |
Share Thread |
| Jun24-09, 02:45 AM | #1 |
|
|
functions in c
can somebody help me on writting a program that displays yo
to yn+1 when n=100 and store them in a file. y"=cos(t)*y+y y(0)=1 y'(0)=0 h=0.1 y'=z z'=z'*cos(t)+y yn+1=zn+h*zn*(cos(tn))+yn) tn=t+nh |
| Jun24-09, 04:03 AM | #2 |
|
|
i have the above using for loop without declaring any fuction,
if someone knows how to solve it including user defined function then he might be able to help me. thank you! the one i wrote is showed below #include<stdio.h> #include<math.h> #include<stdlib.h> main() { FILE *fp; fp=fopen("D:\\cop.txt","w"); float y[100],dy[100],z[100],h,t[100]; int i; y[0]=1; z[0]=0; h=0.1; t[0]=0; for(i=0;i<100;i++) { t[i]=t[0]*i*h; y[i+1]=y[i]+h*z[i]; z[i+1]=z[i]+h*((z[i]*cos (t[i]))+y[i]); } fprintf(fp,"i\tz(n+1)\t\ty(n+1)\n\n"); printf("i\tz(n+1)\t\ty(n+1)\n\n"); for(i=0;i<100;i++) { fprintf(fp,"%d\t%f\t%f\n",i,z[i+1],y[i+1]); printf("%d\t%f\t%f\n",i,z[i+1],y[i+1]); } fclose(fp); system("PAUSE"); } |
| Thread Closed |
Similar discussions for: functions in c
|
||||
| Thread | Forum | Replies | ||
| [SOLVED] sum/integral/zeta functions/ Gamma functions | Calculus | 3 | ||
| Functions and Realtions : Operation on Functions [Please Answer NOW. I need it today] | Precalculus Mathematics Homework | 2 | ||
| Moment Generating Functions and Probability Density Functions | Set Theory, Logic, Probability, Statistics | 4 | ||
| Greatest Integer Functions and odd, even functions | Calculus & Beyond Homework | 6 | ||
| Trigonometric Functions..simplify sin squared functions | Precalculus Mathematics Homework | 2 | ||