c11_ps05_sol

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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
3. Algorithm:
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online