{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

c11_ps05_sol

# c11_ps05_sol - C11 Solutions 1 Count:= 1 FOR I in 1 10 LOOP...

This preview shows pages 1–6. Sign up to view the full content.

C11 Solutions 1. Count := 1; FOR I in 1 . . 10 LOOP If I MOD 2 = 0 THEN FOR J in 1 . . 10 LOOP Count:= Count + 2; END LOOP; ELSE FOR J in 1 . . 5 LOOP Count := Count – 1; END LOOP; END IF; END LOOP; Count = 76. Count increments by 20 when I is even and decrements by 5 when I is odd. 2. Write an Ada95 program to implement the Euler’s 2 nd order integration method? Turn in a hard copy of your algorithm and code listing and an electronic copy of your code.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
C 11 part b ALGORTIHM Eluer’s 2 nd order integration – use trapeziodal rule. Area of a trapezoid under curve = .5*(y1+y2)*delta_x Algortihm: Ask user for inputs: - Coefficients of each polynomial term plus constant - Upper and Lower Bounds of integration - Step Size Calculate number of steps = (upper_bound-lower_bound)/step_size and convert it to an integer Loop from 0 to the number of steps using a for loop, performing euler’s second order approximation - Integral = Integral + .5*(y1+y2)*step_size - Y1 = Y2 - Y2 = Y2 +Step_Size Print out results

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. Algorithm:
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

c11_ps05_sol - C11 Solutions 1 Count:= 1 FOR I in 1 10 LOOP...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online