




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Matlab Programming; Subject: Computer Sci & Software En; University: Auburn University - Main Campus; Term: Unknown 2000;
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!





I
pRrNT' (^) (1X, (^) F6.0, Ttzt F6.2) "I204.899.603. -i- r^ 29tl^
i
o (^3) ,51[- Ll2 3 4 5 6 7 8 e I 1'l I i I : +'l t"i
(1X, (^) 13, 4X, (^) 14) (^) ') 2r799, 9902
,l
1 llq 0 2 E 7 Ble l l T T T T T T 112 2 s
aa bl (^) -lv t nr (^) ry{e711- (^) - - 6 7 Blell 1 1 1 1 111 t 717 2 2
WRITE (*,
I 11?
INTEGER READ (*,
rzJq ;;ZZ
zl'^ (^) -o': :fs o. a (^) z(^ 4 o'7 2 2" .i^'e,r[ l* (^) l_____l_ ___t_ll__l_l s\6 7 8 9 111 1 1 1 1l\1 1 1 1 2 2 212112 2t2^ o'L 2 3 a sl\e 7 I 9 o L z':lq s'e'\
lr^ ."t^ t,"^.^ t
lGt*
WTT Yar2 (^) -D-.j.\
Var3 (^) 47,oL
Ya'r4 (^) rlD. (^) l}?
fr
%
(
Xin liL^ "^ 4-
http:I (^) / web99. auburn. edu/web99 I p99 18/cse (^1) 2Olsamplex2. htm
COMP 120 Fortrnnr Winter 2000
I l('P
SAMPLE BXAM
l. (^) What is the output
--.'--xl
^(,#i*rn
k--!''J?#"^^'
EXAM2 Winter (^2000) Page2 af
var5 (^) ll gb
statement is executed (^) [9 ptsJ?
CHARACTER(LEN: 10) :: Strl8, Str2, Str33, (^) Str4* READ('*,'(Al1,T16 (^) , \ ll, M.,1, (^) A19)') Strl, Str2, Str3,Str
cHanactsn(LEN (^) = 10) :: $trt-
r- I ll I ll / ll I rNpur LrNE: A B C D E F G H r ;lxlr M (^) N O p^ Q R slh u vlw x v z _i (^) _[l L__l____ ,r 2 3^4 s 61 I 9 11111 1 l 1 t 1 1 Llz 2 212 2 2 2 ol1l2 ll 3 4 s 6't (^) B slo r 213 4 5 6
Rut*s! |^
Field width (i.e A7, field width - 7) characters are read (^) from input line (remember (^) tf no frel-d width is speci-fied r-t is equal to the amount of storage for the vareable) tf freld width > length of character vanabLe - right justify (i.e 4. truncate from left) If field wldth < lenqth of qharacter^ variable - Ieft justify (add blanks !o .rest of storaqe)
r\Jl lnvenv
uav t- { (^) - J 11 1 1^1 2 2 2 2 2 2l-^ -^ -l
I t 1 ?'3 4 5 6 7 I 9 r'J. I 1 L 1 1 1^1 ,_:. 012'34s6?B
4thIiLDe: (^) ITHE^ lr KEY (^) To SUCCESI tl \43T5675ETTTTTTTTTTI
3t6ta
OPEN (^) {UN]T - i2, FiLE (^) = F1.LeName2. STA.TUS : (OtD.^ ACTION TOSTAT (^) = OpeDSLatus) iF (^) {Openstatus ]> O) StoF t*,{t error opentrng ft1e2 t+\t( OPEN (^) {UNIT :^ 13, FILE (^) = FafeName3, STATUS (^) = "REPLACE",&
. P.qge^4 af^7
fF (^) {Openstatus > 0) STOP n++ error--opening frfe3 ****"^ IOSTAT':.-.'^ OFensLatrs) o i.t}{ g DO READ {UNIT (^) = 11r lMI (^) = *,^ JOSTAT (^) =.InputStatusl} larl READ TUNIT = 72t FMi (^) = *.^ IOSTAT: lnputstatus2) Var
Var3n/REAt (Caunt)
PROGRAMAPTobIem
IMPLICITNONE
INIEGER :: var1, var2, var3, OpenStatus, (^) Readsbtus
OPEN (UMT (^) = 15, FILE = "INPUT.DAT., SiafUS (^) = 'OLD-, IOSTAT (^) = Opensratus)
IF (Openstatus^ >^ 0) STOP (^) "Error Opening File'
DO
CALL Readlnf{ 1 5, ReadStatus, varl, var2ivar3)
IF (Read8tatus < 0) EXIT
WRITE (t,1F4^ 0), ADVANCE (^) = -NO")^ Calc(varl, var2, var3)
ENDDO
CONTAINS
RINCTION Calc (in1, in2, in3)
REAL. Caic
http.l lweb99. auburn.edul web99 (^) lp99 I 8/cse I (^) 2Olsamplex2.htm 316t
nriscsn INTENT(iN):: inl, in2, in
INTEGER: retValue
IF (ml >^ irt2 AND. in1 > in3)
THEN retValue = rnl
E["SE IF (in2 >^ inl AND. (^) in2 > in3) (^) TIIEN
retValue - rn
ELSE
retValue = in
ENDIF
Calc = retValue
ENDFUNCTIONCalc
INTEGE& INTENT(IN)'. FileUnit
INTEGER" INTENT(NOffi) : ReadStatus
INTEGER, INTENT(OUT)': ml, in2, in
READ (UNIT^ = FileUnil, FMT = i,IOBTAT^ = ReadStatus) inl,in2,in
IF (Readstatus > 0) STOP {at^ Read Enor *rn
END SUBROUTINE Readlnfo
ENDPROGRAMAPTobIem
t What is the output prodrrced by the followiag prograrn with thi input given [12 pts] Input File:IN.DAT 85.3 37.2 9s.8 17.
Page 5 of
#
pts eal
The content of variable FileUnit could be changed by the CALL to the subroutine Readlnfo.
The variable inl is a local (^) variable.
EXAMZ Winter (^2000) PageT of (^7) f.
UseaDolooptoperfonnthefollowing' '',"'l** ' (^) b n*a successtve lurcs of data from an rnput hle iUR!$ that contains a set of data coordinates ( I integer value (Numbet) (^) and one charaetn (Cqmprrtdlion'11^ The variable Comguifficat have two values Terrunate reading using (^) the .tOSfl4T clause feature for detecting end-of-file conditron. O Open a new-file- that contains on each line the vari ables Numbe4 Conputrtion and Resub where Xeyd (^) rs comput€d by using the Conthiffiasforr.rr.ilaif Coarytaion="C" or.PenwildrioarfanmrrJralf Cuttptution-"P" (kisacons:tant)., *
&od,in,drtnnslaorr:@#h ypcmafiitims,,,'^
*' Nurnher!
For each lne, use FANCTION catlsto cslculate the cone spor&ngCombinafons or (^) Permutlions(-5 pts (^) if you don't use FTNCTION calls (^) ) and print it out
,/ ,1 (^) I tn ' y'.,^
'Droblv l"\ (^) , (n'-- r l". Xl 4 \Y. | (^) /nt , (^) -/ t / (^) atr1i u''^^
-l' (^) ' L-(lt''),',,.,r , I f"le"o-t^ tc''(,',-^ .,.,^4 t^ ) L.n, r)) ..,^ l Cl,u^,^ L^'^ A , J (^) ]e,,ty C"oovilol;t 2ll'f'^
qfaTwl
)/ t .t,l '. C)pz-5TL.^ t T ^leeu
'
\ (^) t J.t'r'-( (^) .l l -, 'rl)
t'-
t (^) ()oir+bl'
,Iqula{"-'"r
rl,
((
ir0r
{
7r'
{,
_--
/-/
" "Kr:f
1( (^) !',!*f ," ,t1",
r, - f (^
(,f:n'^"i,t,
|
,) ^ j,J,^ /v',1. I,(
JL'; |^
(-r''-l-of
ii'* '("-f
'+-
l),.\e
A
/, *1. |^ |^ /'-'-t+ W;)"n"^
olrio (^) r .! rllyfv^t
I
. \6- [wr't' V{J I^ r
I ifr'7 ',--'
http:I I w eb99. auburn. (^) ed ul w eb9 9 I p99 I 8/c s e I 2 O/sampl ex2. htm
, (^) i3{.1 $:-,.0^ l 1 t (^) ii, i'.^\
.' ,l i. "., (^) "t .' n,, (^) 4 'l ",'. I^ rii .. ii'.{i';'1 r"}, (^) tL,,, ' .,,.t, (^) " r;t_ (^) ,l (^) I. .;l , I,ld (^) '1 r trr r;,, (^) !. il,-ri:f (^) itl,ii-:
./ '\t-OI (^) L, I-..Vv'
,t
/^.(\ *{;a,"^t[v]^ '^
!t
l" : f-!
I
a
\
t"
l
L
I ,:i"'; i. (^) ,
f
,r
I ,i 'l
,li'l\t
fur-|";ut-
l''b