#include <stdio.h>
typedef double real;
real sine( real x )
int main(void) {
volatile real ostatniX, x, h;
int n, i;
for( n=10; n<=1000000000; n *= 10 ) {
h=1/n;
x=a=0.0;
for( i=0; i<=n; i++ ) {
// printf("%0.15f %0.15f %f0.15\n" , x, sine(x), sine(a + h ) ,sine(i*h));
ostatniX = x;
x += h; }
x = ostatniX;
printf("%12d %0.15f %0.15f %0.15f\n" , n, x, sine(x), sine(a + n*h ),sine(i*h));
}
return 0;
Czy powyższy kod jest dobry, bo chciałabym mieć program, który
mając dany argument x=0.0\ h=\frac{1}{n}, n=10 \cdots 10000000000
liczył
a)\sin(x+h) i kolejne wyrazy
b) \sin(i*h)
i dodatkowo wszytsko musi byc w jedym progrmie