Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
C,C++ Category Code
Real Name
:
SharingCode.NET User
Subject
:
Belirli integral hesaplamak
Description
:
Trapezoidal algoritma kullanarak belirli integral hesaplamak.
#include <stdio.h> main() { float integral; /* Store result in integral */ float a, b; /* Left and right endpoints */ int n; /* Number of trapezoids */ float h; /* Trapezoid base width */ float x; int i; float f(float x); /* Function we're integrating */ printf("Enter a, b, and n\n"); scanf("%f %f %d", &a, &b, &n); h = (b-a)/n; integral = (f(a) + f(b))/2.0; x = a; for (i = 1; i <= n-1; i++) { x = x + h; integral = integral + f(x); } integral = integral*h; printf("With n = %d trapezoids, our estimate\n", n); printf("of the integral from %f to %f = %f\n", a, b, integral); } /* main */ float f(float x) { float return_val; /* Calculate f(x). Store calculation in return_val. */ return_val = x*x; return return_val; } /* f */
Rating
:
0.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks