Skip to content

Instantly share code, notes, and snippets.

@pasali
Created May 14, 2013 21:05
Show Gist options
  • Save pasali/5579547 to your computer and use it in GitHub Desktop.
Save pasali/5579547 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float
F(float x)
{
return x*x;
}
int
main()
{
int n = 100;
int i;
float a = 0, b= 1.0;
float h, sum, sumL, sumU, x;
h = (b - a) /n;
sum = 0;
for (i = n ; i >=1 ; i--)
{
x = a + i * h;
sum += F(x);
}
sumU = sum * h;
sumL = sumU + h * (F(a) - F(b));
printf(" U toplam = %15lf, L toplam = %15lf\n", sumU, sumL);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment