Skip to content

Instantly share code, notes, and snippets.

@TalhaAkkas
Last active December 14, 2015 08:39
Show Gist options
  • Save TalhaAkkas/5059242 to your computer and use it in GitHub Desktop.
Save TalhaAkkas/5059242 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
float
my_func(float x)
{
return sqrt(1+pow(x,4));
}
float
my_integral(float a, float b, float h)
{
float total, step;
total = 0;
step = pow(10.0,-1*h);
while(a < b){
total += my_func(a);
a += step;
}
return total / pow(10.0,h);
}
int
main(void)
{
float a,b,h;
h = 0;
printf("Sayi a yi giriniz \n");
scanf("%f", &a);
printf("Sayi b yi giriniz \n");
scanf("%f", &b);
printf("Lutfen basamak sayisi olarak hassasiyet giriniz\n");
scanf("%f", &h);
printf("Verdiginiz sayilar ile \"sqrt(1+x**4)\" fonksiyonun a' dan b' ye integrali\n");
if(a<b)
printf("%f", my_integral(a,b,h));
else
printf("%f", -1*my_integral(b,a,h));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment