Você está na página 1de 11

?

0o 1
:

D C P2 0 5 3 Fo

Pr o g r a m

r tr a n

in g

e<L:
T h is

e x a m

a n sw e r

PA R T

in

tio

A L L q

c o n s is ts o

p a per

u es

a -

t io

in PA R T A

n s

o u

f tw
,

a n

m m

A L L

e a n sw er

St a t e t h e

es

p a r ts
o n

t io

n a m e

ly O N E q

n s)

m a

fo r

tp u ts

eac

f t he f o l l o w i n g p r o g r a m

s:

(a )
I

10

10

if( I

<

) then

*
p r in t , I
I
i + 1

en

g o t o 10
d if

*
p r in t , I
s to p

en

(b)
I

10

do

h i 1e ( I

<

*
pr in t ,I
i
i + 2
=

d do

en

r in

t* ,I

(c )
20

d o 10 i l

pr in t ,I
10

con

tin

ue

p_
sto p
en

P a ge 1

Scanned by CamScanner

ly PA R T A

f 11

u es

t io

a n

P A R T B P l ea s e

i n P A RT B

[n

D C P2 0 5 3 F o r t r a n P r o g r a m

u es

in g

rt m o m a

S ta te t h e

fo

o u tp u ts

r eac

f t he f o l l o

in g p r o gr a m

s:

(a )
I

10

p r in t
if( I <

10

'

*
,
=

d I

An

en

p r in t
d if

>

t #', I

then

i i

s ta te m e n

'
,

if

<

sta

te

t he

m en

t #'

g o t o 10
en dif
do

hi le ( I

p in v ,
I
I 2
r

>
1

h ile

ta te m

en

t #'

d do

en

d o 20

20

p r in t
n t in u e

co

*
pr in t
s t0 p

en

I,

'
,

'

do

en

3
s ta te m e n

sta

te m

en

t #',

t #'

(b )
i n t ege r
0
x

10

BET A

do

Scanned by CamScanner

2 5

h i l e (i

x /

x +

<

N)

2 / (i

3)

(I

BETA

)/

D C P2 0 5 3 F o r t r a n P r o r a m
g

Q u es m
O bs e r v

0 11 0
t he

in g

ks)

m a r

f o l l o w in g p r o g r a m
in te ge r

su m

d a ta M

do

h i !e ( k

M fa

M fa c , N f a c , P fa c ,

Qf a c /

7 , 5 , 8, 6, 7 , 5 , 8, 6 /

<

M fa c

"

(M

k)

do

h i l e (k

N fa

N)

<

N fa c

(N

k)

d do

en

do

h i l e (k

Pfa c

P fa c

p)

<

"

(p

k)

d do

en

d do

en

N, p,

Qfa c Q

P fa c ,

do

h i l e (k

Qf a c
k

Q)

<

Qf a c

(Q -

k)

d do

en

su m
w r

M fa c

N fa c

P fa c

i t e (6 , 1 0 ) M , N , p , Q, s u

Qf a c

sto
en

(a )
(b )

p
d

S t a t e t h e o u t p u t s a f t e r t he p r o g r a m ha s b e e n
C o n v e r t t he p r o g r a m by u s i n g a f u n c t i o n

Scanned by CamScanner

e x ec u ted

m in

D C P2 0 5 3 F o r t r a n Pr o g r a m

4 (a m

ks )

O bs e r v e t h e f o l l o w i n g r o r a m
p g
* '
p r in t , k ey in
r ea d * a b c
,
,
,

i f (a

c :

'

0) t h e n

Ne
ca

b,

a,

ll q u

d (a , b , c )

e ls e
*
p r in t
d if

en

sto

n v

a 1 i

Equ

t io

IW

e Dd

su

br

o u

t in

q u a d (a , b , c )

b b 4 a
y
i f (y < 0 ) t h e n
-

p r in v
e ls e if( y x

'
,

Im

*
p r in t

'
,

gi n a r y N u
0) t h e n
a

b / (2

a
'

be r l !! '

)
x

e ls e

( b
( b

p in t
*
p r in t
r

Fo r

(a )
(b )
(c )
(d )
(e )

eac h o

0 0

en

dif

en

+ sq r

'

R o o t #2

90

10

2 0

3 0

2.0

2 0

4 0

I 0

0 0

4 0

3 0

0 0

12 0

Scanned by CamScanner

t (y )) / (2

R o o t #1

f t h e f o ll o w i n g i n p u t s
10

t (y ) ) / ( 2

'

sq r

'

a
*

'

s t a t e t h e o u t p u t a ft e r

t h e p r o g r a m h a s be e n e x e c u t e d

D C 2 053 F
m

t be

P+:vgi uruTwg

fB}l wing& o g r a m
i n t ege r A 5
( , 6)

Open{ r 1l e= s o a l 5
'

do

1 0 l

'
L o u L t t )

d o 10 6 1 6
,

(a )
(b)

A (j

1o

m n t in u e

20

fo -

t { 6{ 3yj

St a r e t he o u t p u ts a f t e r t h e
p r o g r a m ha s be e n e x e c u t e d
M o d i f y t he a bo v e r o r a m tr d i l
o
p g
s p a y t h e f o l l o w in
g m

Scanned by CamScanner

10

11

13

15

11

17

20

13

17

21

25

10

15

20

25

30

II

17

23

29

35

a t r ix

P 1u g r a 1 -

D C P ? O SJ F o -

Ou Et i o n 6 ( I O

m a r

ks)

S u p p o s e t ha t F u n c P H (p h ) i s a s u b r o u t i n e
U s e a m u l t i p l e a l t e m a t i v e i f : e l s e i f - e 1s e f o

w r

ite

in te r m

f l l w i n g Ho w
p r o g r a n 1 tb r t h c o o
ib le
o
e d i a te d e c i s i o n s w he r e p s s

f unc H
F
M
H
M
H
M
H
M
(H
ph)

K4

ha r t

N= 10

No

S j

ph

T
.

Y1 s

Al k a' " *

4 M

J
/

R1 l u m

Scanned by CamScanner

n C P 2 0 5 J Fo r t r a n P r o g r n m

mk o n m

m 1n

ks )

m a r

in tege r

d*

r ea

su m

fu

n c

su m
a

ifu

*
p r in t
s to p

en

'

(a

su m

t io

y)

,
'

su m

ilu

(r

p, q)

in t e ge r p , q
c ha r a c ter r

i f(

'

'

then

d o 10 I p , q
=

10

t in

con

ifu

n +

e ls e i f (

u e

'

"

t he n

do 20 i p, q
j = j* i
=

20

t in u

co n

i fu
e ls e

i f(

' "

then

do 30 i p ,q
=

j
30

t in u

con

i ti 1n

if u n

j*

e ls e

Fo e e a c h

en

dif

en

f the s t a te m

e n ts

be lo w

e x e c u te d

(a )
(b )
(C )
e

ifu n (

'

su m

ifu n (

'

s ln

su m

su m

su m

Scanned by CamScanner

"
,

'

i fu n e *

7 7)
,

14 2 0)
,

1, 5)

i f u n ( % , ] 2, 18)
i f u n (5 6 8)
'

'

s t a t e t he v a l u e o

f t he

s u m a ft e r t h e

pr o gr a m h a s be e n

0 0 P2 0 3 1 > 1r l N rn 1T 11* 1 n r n r r l 1r u

(n )

r t 11c I l ) l l n w i w H l w r l t h m ;
n l t i I i X U , 2
S t e p 2 W h i l e x : 4 d n l h n l Btl l twit+H:
Se l y
y A
Bl
x I n r t t l I I C I I i r 1t , r c n i e l l l x 11y I
z
b 1r A
1 t he n

( : m M1i

S . ) I

Se . z
) iw l a y A

s,

nn (l

H x
,

* 4

:t n t l

l llc

1 l

r i #c

l ;

Ste p 3 s t o p
Co

rn

p le tc t hc fo l lo

s ta t e m e n ts
s ta

in t hc

i n g t r n c e t n f l e l b r t h i n i H o r i t h t n w l l i t : h di pl i ryn t b 1a b l f i } f t r e
r d c r i n w h i c h t he
y a r e e x e c u t e d i t n d t h c v a l r1c } f l l l c v a r i a b l e n a t C Ul ( ; Bl
w

ge :

Ei

n o

l=

x
l
: 0

25

25

(b ) C o n s id e r t h e f o l l o w i n g
1

a l g o r i t hm :
E n te r A
W h i le A [ 0 3 d o t he fo l l o w i n g :
I n c r e m e n t A by 0 1
a

I f A 0 3 t he n d o the f o l lo w i n g
I Se t s a n d x t o 0 T t o 1
,

ii

W h i l e T 5 4 d o t he f o l l o w i n g :
( a ) Se t x x + T a n d t h e n i n c r e m
=

E l s e d o t he f o l l o w i n g :
I Se t T t o 0 x t o 1
,

ii

Dra w

d t he n i n c r e m

ent

T by 2

s hy 3

W h i l e T [ 3 d o t he f o l l o w i n g :

(a ) I n c r e m
d

an

en t

D isp la y A s
,

and

en

t T by 1 a n d t h e n s e t x

St o p

f l o w c h a r t f o r t h i s g i v e n a l g o r i t h m T h e n s t a t e t he
tha t t h e g i v e n v a l u e is e n te r e d f o r A is 0 1
a

Scanned by CamScanner

o u t p u Ls

pr o d u c e d ,

a ss u m in

D C P20 5 3 I : o

m
u

r t r 1u 1

p ru w

m! wuQ ! v -

S u p p o s e t ha
t

T im

tu n r r r i n

t io n ,

e 1 a )
de v ic e

m o n i to r in

pr o c e ss

rec o r

ds t im

te m

pe r a t u r e

an

d pr ess u

re an

in p o s i t io n s 1
4
T e m pe r a t u r i
e n
i
o
s
t io n s 5 8
p
P r e s s u r e in
i
o
P s t i o n s 9 12
V o l u m e in o i
p s t i o n s 13 16
e

0 7 3 0 0 4 4 2 13 2 2

10 15

0 8 3 0 0 4 8 8 14 2 2 1

12 1
0 9 3 0 0 5 4 8 14 5 4 14
25
1 0 3 0 0 5 5 3 14 8 0 1 5
20
l 1 3 0 0 5 7 5 1 5 1 8 16 6
5
1 2 3 0 0 6 2 3 15 1 9 1 8 6 5
13 3 0 0 6 5 5 15 2 3 2 0 8 0

1 4 3 0 0 7 l 1 15 2 8 2 2 6 2
15 3 0 0 7 5 8 16 2 5 2 5 6 4
1 6 3 0 0 8 2 5 16 2 7 2 8 6 9
1 7 3 0 0 8 6 9 16 3 0 3 18 6

T he

v alu e

fo

t im e

is a n i n t e g e r r e r e s e n t i n t h i
p
e t m e a t w h ic h t he m
g
eas u r e m e n ts w e re
f o r te m pe r a tu r e a n d r e s s u r e a
r e f l o a t s bu t a r e r e c o r d d
p
e
w ith n o
d e c i m a l p o i n t E a c h m u s t be i n t
e r p r e te d a s a f l o a t v a l
u e ha v in g a d e c i m a l
p o i n t be t w e e n
t h e th i r d a n d f o u r t h d i i ts
g
ta k e n

T he

v alu es

W r ite

fr o m

t h e a bo v e

p r o gr a m t ha t

9 :30 A M

r e a d s t he t i m e t e m e r a t u r
e pr e s s u r e a n d v o lu m
p
e m e a s u r e m e n ts
d a t a f i l e ; c o n v e r t s t h e t im e f r o m
m i l i ta r y t o o r d in a r
i
t
y m e (e g 0 9 3 0 i s
153 0 i s 3 : 3 0 p M ) ; c a l c u l a t e s t h e
av e

a v e r age v o l u m e ; a n

TIM E

7 : 30 A M

5 : 30 p M

v er a

ge

( w i t h t h e ?s

d d is p l a y s

r a ge t e m

ta bl e l i k e t he f o l l o w i n :
g

T E M P E R A T UR E

pe r a t u r e

P R E SSU R E

a v e r a ge

13 2 2

10 1 5

86 9

16 3 0

3 18 6

?
r ep la c e d

by t h e

a ppr o

pr i a te

a v e r a ge s

f l l

pr e s s u r e

VOL UM E

44 2

Pa ge 9

Scanned by CamScanner

An

D C P 2 0 5 3 Fo r t r an P r o r a m
g

es

W r it e
co m

t io

1 0 12 0

in u t e s

ks)

c a lc u la te s a n d
p r i n t s t he b i l l f o r a c e l l u l a r te l e p h o n e c o m p a n y T h e
t w o ty p e s o f s e r v i c e s n a m e l
y , r e gu la r a n d pr e m iu m It s r a te s v a r y
t h e t y p e o f: s e r v i c e s T h e r a t e s a r e c o m u t e d a s f o l l o w s :
p

f fe r s

o n

d u r in g the da y

Pr e m iu m
a

m a r

in g

p r o g r a m t ha t

pa n

y
d e p e n d in g

s e r v ic e :

Fo r

ca

o v er

b) F o r
o v er

d the

ig h t

f la t

r a te o

f R M O 20 pe r

in u t e

are c

h a r ge d

R M 2 5 00 p l u s :

lls

10 0

ca

an

l ls

15 0

m a de
m

f r o m 6 0 0 a m t o 6 p m t h e f i r s t 10 0
i n u t e s a r e R M O 10 p e r m i n u t e

m a de
m

fr o m 6 00 pm t o 6a m

i n u te s

are

R M O 0 5 pe r

t h e f i r s t 150

in u te s

a re

f r e e ; c h a r ge s fo

i n u te s

are

fr e e ;

h a r ge s f o

in u t e

p r o g r a m s h o t 1l d pmmpt t h e u s e r t o e n t e r a n a c c o u n t n u m b e r a s e r v i c e c o d e (t y p e
c h a r a c t e r ) a n d t h e n u m be r o f m i n u t e s t h e s e r v i c e w a s u s e d ; a s e r v i c e c o d e o f t y p e p o r p
m e a n s p r e m i u m s e r v i c e w h e r e a s c o de o f r o r R m e a n s r e g u l a r s e r v i c e T r e a t a n y o t h e r

Yo

ur

ha r a c te r

n um

be r

Y o u r p r o gr a m s ho u ld o u t p u t t he a c c o u n t
u s e d a n d t h e b il l a m o u n t d u e f r o m t h e u s e r

a s an er ro r

in u t e s

nu m

be r t y p e
,

s e r v ic e .

F o r t h e p r e m i u m s e r v i c e t h e c u s t o m e r m a y be u s i n g t h e s e r v ic e d u r i n g th e d a y a n d th e
k t he u s e r t o i n p u t t h e n u m b e r o f
t
n i g h t T h e r e f o r e t o c a l c u l a t e t h e bil l y o u m u s a s
,

i n u te s

t he s e r v i c e

w as used

Scanned by CamScanner

d u r i n g t he d a y

an

d the

i gh t

2 0 5 3

Fo

rtm

Pr o m

in g

U ma r k s )

T h e d is ta n

ce a v e

h ic l e

D I STA N C E
Fo

r ex a m

p le

if

tr a v e ls c a n

be

ca lc u la te d as

fo llo w

S PE E D x T IAI E

t r a in t r a v

e ls

5 0 km pe r ho

u r

fo

4 ho

u rs

t he d ista n

c e

k m p e r ho u r ) a n d h o w
m a n y h o u r s it ha s t
r a v e l e d I t s ho u l d th
en u se
d is t a n c e t he v e h i c l e h
as t r a v e le d fo r e a c h h
o u r o f t h a t t im e
pe r io d H
t he o u tp u t :
E n t e r t he
E n te r n o

o u rs

s pe e d o

f th e

v e

f ho u r s it has t r a v e le d

D is t a n c e t r a v e l e d
50

10 0

150

2 00

2 50

Scanned by CamScanner

h i c l e (k m
:

)
5

50

tr av e le d is 200

l o o p t o di sp l a the
y
e r e is a n e x a m l e o f
p
a