/* Calculate the integration of 2 dimensional function f(x, y)=sin(x)*sin(y) The true integral is cos(1)^2-2*cos(1)+1 */ #include #include #define x0 0 //beginning x value #define xn 1 //ending x value #define y0 0 //beginning y value #define yn 1 //ending y value double f(double, double); double f(double x, double y) { return sin(x)*sin(y); } main(int argc, char** argv) { int n; //number of rectangles double h; //width of each rectangle, (xn-x0)/n double sum = 0; int i = 0, j = 0; printf("Number of rectangles: "); scanf("%d", &n); h = ((double)(xn - x0) / n); printf("x0=%d, xn=%d, y0=%d, yn=%d, n=%d, h=%lf..\n", x0, xn, y0, yn, n, h); for (i=0; i