Sheet1
Page 1
/*
MAE 9:
Homework #5, Fall 2008
Due on Monday, November 3, by 9:00pm
Scan two doubles a and b (a<b).
Integrate numerically y=0.5*exp(sin(x))1.5*pow(x,2)
from x=a to x=b. Use the program based on trapezoidal
rule of integration discussed in class (Problem w410.c
from subdirectory /public/lecture/week4.c).
Use two do/while statements to continue
the calculations for different n_trap and different a and b. For
example, use ask=1 to continue calculations for different n_term
within the inner do/while loop, and ask=0 to exit that loop.
Use flag=1 to continue calculations for different a and b
within the outer do/while loop, and flag=0 to exit that loop.
.................................................................
Your output should look like this:
iacs5.ucsd.edu% gcc hw5.c lm
iacs5.ucsd.edu% a.out
a and b:1.2 2.05
Enter the number of trapezoids:
100
n_trap =100
del_x =0.0325
Integral =
.......
Do you want new n_trap: y=1/n=0
1
Enter the number of trapezoids:
1000
n_trap =1000
del_x =0.00325
Integral =
.......
Do you want new n_trap: y=1/n=0
0
Do you want new a and b: y=1 or n=0
1
a and b:0.5 1.25
Enter the number of trapezoids:
100
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Lubarda
 ........., Trapezoid, #include, scanf

Click to edit the document details