PART I(b) Provide your selections to the following using the form provided as pa
ID: 3731260 • Letter: P
Question
PART I(b) Provide your selections to the following using the form provided as part of the lab submission template FOR LAB EXERCISE SET THREE posted on myCourseLink sleet% cat e6.f90 ! The folloving program generates a table of I values for points (x,y) on a line through (x1,y1) and 1 (x2,y2) ! The function interp returns the interpolated value y ! for the input value of x and the given points on the line PROGRAM P6 IMPLICIT NONE INTEGER: 1 0 REAL x1-1.0,y1-1.0,x24.0,y2-9.0 REAL : del-.5, x0 1.0,x,y print "(1x,"."y" do i-1,10 print "(1x, 2f10.2)",x,y end do 5 function interp(x, x1,y1,x2,y2) real, real m --': x, x1.y1,x2,y2 n-(y2-y)/(x2-x1) interp 7 +y1 --8 function interp END PROGRAM P sleetx f90 e6.f90 sleet% a.out 1.00 1.50 2.00 2.50 3.00 3.50 4.00 4.50 1.00 2.33 3.67 5.00 6.33 7.67 9.00 10.33Explanation / Answer
Description :-
By simply running the code on a machine the following are the results :
sleet% cat e6.f90
! The following program generates a table of
! values for points (x,y) on a line through (x1,y1) and
! (x2,y2).
! The function interp returns the interpolated value y
! for the input value of x and the given points on the line
PROGRAM P6
IMPLICIT NONE
INTEGER :: i=0
REAL :: x1=1.0,y1=1.0,x2=4.0,y2=9.0
REAL :: del=.5, x0=1.0,x,y
x=x0
print "(1X,A10)","x","y"
do i=1,10
y=interp(x,x1,y1,x2,y2)
print "(1X,2f10.2)", x,y
i=i+1
end do
FUNCTIONS
return real function interp(x,x1,y1,x2,y2)
real, PARAMETER:: x, x1,y1,x2,y2
real m
m=(y2-y1)/(x2-x1)
interp=m*(x-y1)+y1
end function interp
END PROGRAM P6
sleet% f90 e6.f90
sleet% a.out
x y
1.00 1.00
1.50 2.33
2.00 3.67
2.50 5.00
3.00 6.33
3.50 7.67
4.00 9.00
4.50 10.33
5.00 11.67
5.50 13.00
sleet%
SELECTIONS FOR BLANK NUMBER 1
(a) 10A,10A
(b) A10
(c) 2A11
(d) 2A10
(e) 2I10
ANSWER :- for this blank the answer should be (b:A10)
SELECTIONS FOR BLANK NUMBER 2
(a) y(x,x1,y1,x2,y2)
(b) function(x,x1,y1,x2,y2)
(c) interp(x)
(d) interp(x,y,x1,y1,x2,y2)
(e) interp(x,x1,y1,x2,y2)
ANS :- For the above it should be (e:interp(x,x1,y1,x2,y2))
SELECTIONS FOR BLANK NUMBER 3
(a) y=y+del
(b) x+=del
(c) i=i+1
(d) x=x+1.0
(e) x=x+del
ANS :- For the above blank it is (c:i=i+1)
SELECTIONS FOR BLANK NUMBER 4
(a) SUBPROGRAMS
(b) FUNCTIONS
(c) USES
(d) HOLDS
(e) CONTAINS
ANS :- FOr the 4th blank option is (b:FUNCTIONS)
SELECTIONS FOR BLANK NUMBER 5
(a) real
(b) return real
(c) real y
(d) real returns y
(e) INTENT(real)
ANs :- The answer can be justified as (a:real)
SELECTIONS FOR BLANK NUMBER 6
(a) intent:IN
(b) IN
(c) intent(IN)
(d) PARAMETER
(e) int(IN)
ANS :- The option is (d:PARAMETER)
SELECTIONS FOR BLANK NUMBER 7
(a) x
(b) x1
(c) (x-y1)
(d) (y-x1)
(e) (x-x1)
ANS :- The option is (c:(x-y1))
SELECTIONS FOR BLANK NUMBER 8
(a) stop
(b) end do
(c) return
(d) contains
(e) end
ANS :- to justify to end the function use option (e:end)
Finally the options are ;-
(1) b
(2) e
(3) c
(4) b
(5) a
(6) d
(7) c
(8) e
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.