You are on page 1of 13

I

M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 202211

MAHATMA GANDHI SCHOOL


JI. Tabing Blok B-16 No. 3 Kemayoran
1st Term 2022

: Computer Science (Practical)


l"\~~~cl-e_..-._A_11_-\_h0i1y
Name : _ _ v·111a\l'A
Subject
Grade :XII Date
Max.Marks : 50 Time : 1hr 30 Min

Roll No.
Invigilator's signature: -------
Mark Obtained: _ _ _ __
Examiner's signature: _ _ _ _ _ __

Instructions
There are 12 pages including this page in the question paper.

All 10 questions are compulsory.

Write in the space provided.

Draw diagrams neatly and label them.


An extra sheet can be attached if the space provided in not sufficient.

Only blue or black pen is allowed.


M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec ioii\ l

Q.1 (a) (i) Procedural high-level languages usually su ~port diff~rent data types. Give an
appropriate data type for each data value in the following table.
- - -
Data value Data type
FALSE l3M~tt\~
03/03/2013
~Mt.
35 1~Vco~tt.
"INTEGER" ~-m,~1.
3.5
R~ft..L
" 35"
e\\~i
(6)
(ii) The following is a declaration in a high-level language:
DEFINE MyGrade[1 to 100]

State the data structure of variable MyGrade .


.................. ..... .. .. ... .. .. .. ...-~~~~J...... ..... .. .. ... .. .. .. ... .. .. .. ..... .. .. .. ... .. .. .. ..... .. .. ... .. .. .. ....... .. .. .. [1]
(iii) An experienced programmer is presented with program code in an unfamiliar high-level
language.

State two features of the code that the programmer should be able to recognise.

1 ................. J .t'.\\e.t\\ ~~~.<?.~..... -~-~~-'t~ .....~-~- ... -~~!: .. -~~!.... .. ... ...-~-~-~! .. --~~- -~ ~:... ~~-'I l
Ill\~ \~ L

~--_-_-_-_-_-_-_-_-_-_·_·_3~~::::::::i~;~;,;;~.- :.-.-:;~;_·:_·.-:.-;;_;_;_;_~;~_-_·_·_:·.~~;_;:·.::·.:·.~--:\;!:;~::~:~i~;;~::.- :::::::.·:::···


...... .... ....... .. .. .. .... ... l~~-~~~~:.......... ... .. .. 111
M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 202213

02 (a) In the ASCII character set 'A' is represented by the value 65.
The values representing the other characters of the alphabet follow in sequence, so 'B' is
represented by 66, 'C' by 67 and so on.
The following table represents consecutive memory locations. Each memory location stores
one byte. Complete the table to show how the string "CAGE" may be stored in memory using
the ASCII set. A ' , 61
C:,I
t 68 O c;gE; 10f' 11
G

Address Data
G1
100 67
c;,r
101 €15
7\
102 71

103 69
104
.
J
105
[2]

(b) Functions and procedures are subroutines. Explain why parameters are used with

... . . ... . ~fi.J~... ...... .... ...... .....~~··················


......v\ctt~~~t).~·~·· •·f~·~t- •·~~~~!t·,~:~.· \· · 1::·t·u:............................................................
~ ~?·~·i~r:~; · 7~·· ·~t:t\·;·~;~···· · · ·.
l"-'~~""-·· .a......lj i<i~i1~.......................................
··········1'&\t ............... ........................... .................. ........

...:' :'.~. . .
1
I< ·····l'"''6~11A-.... .,,, .... At1n11.1"" .... ~ho.\. .. ·· ........\!!- .!s ... ,~!!'. ........... .
~~~\~.~~.<N!.... ....~.~! ..... ... !t ... .. ~.~.".1!.~\~~....:~...... .
·········--·······.................... .................. ..... ........ .......................... ........... ................ .......... ........ .. (2)
M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 2022 \ 4

03
The following pseudocode is an example of a CASE structure.
CASE OF MyMark
75 to 100: MyGrade "Distinction"
35 to 74: MyGrade "Pass"
0 to 34: MyGrade "Fail"

OTHERWISE: OUTPUT "Invalid value entered"


ENDCASE

Describe what will happen if the pseudocode is tested when MyMark has the following
values:
.
27 .............. ......... ... .. ........C?.~.~j~~..... ::.:.~.\ .. ::........................................................... ..
······················· ·· ························· ······· ... ,......... .................... ................................................ .
101 ................... J~ ......~~\\ ... ...:.. .. .~\~.....~.!>:\~.~ ..... .......................... .......
................. .. ........ .................. .............. .. ..... ........................... .. ........ ...... ............................ .. [2]
M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 20221 5

Q.4
Jemma is designing a program that will work out the end of year bonuses for her
I employees. The main steps are:
\• input employee·s data
• calculate the bonus
• calculate deductions
o tax
o optional contribution to charity
• print out the bOnus
(a} Draw a structure diagram to show the modules that will be needed.
[3]

(b)

(i) Jemrna is using the variable Percentage in one module and a different variable
called Percentage in another module.
Explain the feature of a high-level programming language that avoids any possible
conflict
.....J.t.....~.'?.~...... ....!.. ..... ..... .... .... .... ...............
...... ....~.?.~.~... ... ... .... .... ~~.?.~ .. ~~~::.
-inu u oa\\o6 ~o,!:\MO{~'ii,\~. It \ 1 IA)\,er, ~ht 1Jllnohlt1 ote
......................................................... ................................................................................
.. .. . . . . J.~'..~~~~.~~::.................................................................. [2]

(Ii) Some modules require data values that originate from another module.

Explain the feature of a high-level programming language that enables this.


'i~e tea\01t is eo.\\t~
.........................................................................................................
. . . . . . . . .~;:·:. . ·~~·~:; ~·. · ~·~~:. . ~;:·;:·. .;~. . . ."C::~~·...................... ~·;~;. . ....... . ...
I)\ l'lli\ \(\'nt\'~o.11tt1 ,\' \I

,, .,

,.,J~~•••"~~~.....
S~\'l\t M.\c, \)d\Ut>
.. ....
o.~
.....
ti> ~\ ll\e&. 11-t
.... I ~~I.
H\e,,e~t: ....................... ...
................................................................................................................................... (2)
M.G.S/Cornputer Science/Gr:12/Terrn 1/Nov-~ec 202216

(c)

I Jemma is designing a range validation check for the input of an employee's pay. The
pay range depends on the employee's job type, which may be P(part-time), F(full-time)
or C(commission only).

• A part-time employee will earn between $100 and $10000 a year.


• A full-time employee will earn between $5000 and $50000 a year.
• A commission only employee will earn between $0 and $80000 a year.

Complete the table showing five more rows of test data. Give a different reason for
each, describing what is being tested.

Job type Pay Reason


F 25000 Normal data - within pay range for full-lime
p .,ooc, l""l\\il\, ~o.\,- ,- n,t {A)1\n\.- ~~IA '°"gl tOf ~o.i\·\\l\l

c:. ao.roo E~t,el't1t h,\0,,) .\lo.\io Ill i\ ·,i . I>.\ ~k e4,t Q\ bl)lt<bl~
V lo\ol.) 13oonalM~ Oo.to.-" ?i~~t oho'(\ -\\. ~DWlb\~ ,

5 t\~1\0\M,\ '\)(U11. -"1 ~~0{1'11:1.\ l\(}\O \ll}.\Ul .\\\O.l t\oelJ\ reer,, reo,onaMe.
p 9() \3cu"~~,, 'ba\o- -') be\ow \'11t 1',1\1\l t'tlU.\" ~C>U\t\W"

[5]
M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 202217

05
!Soni works for a S?ft'.""are house which has been asked to design software for Super Bikes, a
I company that spec1ahses in hiring out motorbikes.
[fhe t~pe of each bike is also recorded. The intention of this pseudocode is to allow
pnly tnal. scooter and road as valid bike types.
I
!INPUT BikeType
IF ((BikeType = "trial") AND (BikeType "scooter"))
OR (BikeType "road")
THEN
OUTPUT BikeType \\ is valid"
ELSE
OUTPUT "Invalid"
I NDIF
~ tate the output when the BikeType input is:

lh~a.\\i - - .. , ·
scrambler .............................................................................................. 1., ••••••••••••••••••••••

trial •••••••••••••••••-'-''•n•••••••••••
"\ ·,\ ... ~I\\\~ -· · ·
:r................................. ,•• ,....................,,.................
, · ,•• ,•• , •••••••••
'

!!..... .. ........:...... .................·..........·....... .............."...


'("

road .".................. .... (3)

Ii Rewrite the line in the pseudocode in part which needs changing in order to
1 correctly validate bike types.
;·································z.
}(-/ ;e>'r'1'~-1-~~ ......•.............................................................................•.......................
.......................................................................................................................................... (1)

\F 11\t&,~,c "-- '"~\,


1\\'c~ ,. •I

t~~,,.,.
O\l'\V\J:\ \lo.\\!\

W 8\t,.e~~V' <. - HOO'ter


,..~~ 011-W\1'\ JI-,
'-'
t ~\\6
"

~'1\t

\f \\i'#..t\~\t L- \00-0 .
M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 202218

0.6 Write a short program to declare the class shape with the public method area. Declare the
derived classes circle, rectangle and square. Use polymorphism to redefine the method area for
these derived classes. Declare objects for each derived class and instance them with suitable
data. Use your methods to display the areas for these shapes. [5]

..... ~\().\\ .... ~))~,~ 0


... .......................................................................................... .
....... ...... .~~.\ ,.,.,,. \t>1~...,.,.,...~~~\~) .. .......... .... ............... ............................... ............ .
·· ·· ······· ···~~.\.t_~~~~.~~~.:. ··0··· ······ ·· ····················· ··········· ····································
······················································································································
.............. M.\... 0:WOUt\\\
................ l\t\t .C~ ),\~~·· \i ... ". ·; · ~~,·, ~·· ·~;~
~·4\~·~"\ ............................................
? .... ·················~·················································· ········
:···················~~\
::::::::~,~\~:::~~i..t~.\i:-~
:~:~~~,~\::::::::::::: : : : ::::::::::::::: : ::::::::::::::::::::::::::::::::::::::::::
.. ,.,.,.,._ ..\.~~\h. ,o.~\~o
....................~.'n~,~ .•. ~-.V)\"; ... ... :::: :::: ::: ::::::::::::::::::::::::::::::::::::::::::::::::::::::
~"-\. - ,o.~~-. t'o.~\Ul
: ::::::::::::::~~;:: ;~~:~~:~~:·: ::::::::::::::::::::::::~::·::::::::::::::::::::~::::::::::::::::::::::::::::::
...................... -·c· :.,·........ ·:. °'.,. .. ........................ ..... ....... ........ ............... ... ......... ..
St\\. P..'f<l"~\\lh l~\l. - l<l<.\.\~ rt\\, _t0.6.\U.\ 'lr)1'\'l..
................. ......... ... .... !.. ~-;;. .. :...................................... .

:::::::::t\~~:::::~~~~~:::c0~t\~::~~,<~~:;~~:~::_:.;_:,::::::::::::::::::::::::::::::::::::::::::::::
\h~ e
···················~··\~............ '"\\·· ·(j~,,,. 1\1 ••••••••.•••••••••••.••••••••••••••••••••••..••• •• •••••.•••• • ..••
.-1.1:

····················· · ·''··"·.,.,-:"······················· '·· ··· ·········································· ··············


·····················!·:~t:=\~~~~~:~~:~~~\(:· ·· ·························································
:::::::::::::::~:~~:::~;:~:~,~~~~:~::::::::::::::::::: :::::: ::::::::~::::::::::··················· ···············
····················~~~.~.:.-:-:..~t~.~~\~~ :.7...~~~.!.77.~~.~~t.:.... ~~\\~.:;~~~:~~~:::::::::::::::::::::
.....................~~~I\\ .. \. ...... ..~\ ... .. ."!~.·.~.~.~~\·. 77: !?!~~ ......... ........... .

::::::::i:~~~:: : : :~ ~~:: \~~:~,~?: :~: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :


..••....... ........~~., _.......)'(-.)\:"..........\ .. s•...~'. ~~:. ........................................................... .
....................~)l~t! ..,..,.,J~.S~~\ ............................................... ... ......... ........ .
'ie\\ o _ ~\de!.-; S\d<.
················ ························o··············· ···· ············ ··········· ······ ····························
.. ......... ..... ...~~~\~~\_~~····· ···· ············· ··········-v········
·.................
················nn~\:..l
··········...................
~ .- ·;:,;~·~··°'~ ·· r. ..........................
iG\\o-~ne(ll.\16.\~v SeHo- s\~t
i• · · ·
lt\\o.~(\~t······ ·················· .. ··· ·
ia"i ~· ·: "A",·en~·~,~e..\ ··········································
r ···········································
.'
································································································································
"1111\1- .,,_\l') \,\ ...................... ........................................................ .
.. .. .. ··, ···················································································
.. ················································································
\ \,)
.. ···················································································
.. 0\l). ·e~~~\\\············································································
······· ··········· ·· ·· ············································ ······························
m~e\n,\t :. e'l,t.\t t2.\\
l'tt'l t\\t\t. dtfM.\
Nl\_\\et.\01\Q\t Ut.\:Ol\i\t
~tet\M9\t • l\~.Clt\
l'\~l(\UMt,. l(\UC1\1. \, "'\°)
l'fl~~~UO.\t I <)HQ.\,\
M.G.S/Computer Science/Gr:12/ Term 1/Nov-Dec 202219

0 7 Writ~ a short program to declare a class, student, with the private attributes name,
dateOfB1rth and examMark, and the public method displayExamMark. Declare an object
myStudent, with a name and exam mark of your choice, and use your method to display the
exam mark. [5)

~,~r. '""'~ee..\
······················································································································
........ .. .. ....~~\.~)1\~.=-.(.!.~~~i .. .. .. ............................
. . . . . . . . . . . . . . . . . . . . . . . . . ,~,~ :o.,..,-.~().Sll.1?,~..1'.\.Q.!!I.~ ........... .... ............. .. .... ...... ... .. ..... ..... ..... .... ..
......................... :7. -~~~~-~\~_\_~\ ... .. .. .. .... .......... ... ....... ... ......... .

. . . . . . . .. . .. . . . . . ... ..... ~. :-:-: .~ ...... ............................................ .

································································································· ·········· ···········


······················································································································
······················································································································
··············· ··· ··············· ·· ············· •···· ······ ··· ·· ······················································
······················································································································
·························· ·························································· ··································
·············· ·············· ········· ···················· ·· ··· ······································· ·········· ·······
··········· ·· ·· ············· ····· ·· ·········· ·········· ··· ·· ··· ············· ····· ·· ··· ····· ·· ······· ···· ······· ·· ·····
··· ··· ·· ······· ·· ···· ······,··························································································
······················································································································
······················································································································
······· ······························ ·· ······ ·············· ·· ··················· ·· ··········· ·························
··························································································:·············· ············ ·
······ ··· ············ ········································ ··· ·· ·· ······················· ··· ············ ············
·· ·· ······ ·············· ··············· ······ ··································· ·································· ····
······················································ ····· ·· ···································· ··· ··········· ·······
···· ··············· ····· ······ ··· ············ ··· ·· ····· ·· ·····························································
········· ········································································································· ····
····························· ········ ············· ·· ··································································
················ ···· ······ ············· ·· ··················· ·· ·························· ····· ··· ······················
······················· ······ ··· ·· ··· ······ ··· ·········· ·· ··········· ····· ········· ········ ·· ····· ······· ········ ·····
·················· ···························· ······· ······ ····· ······ ······ ············ ·························· ···· \

··································· ····························· ············· ·············· ········· ·· ················


······················································································································
······················································································································
······················································································································
·· ··· ·· ··· ··· ···· ·· ···· ······ ·························· ···· ········ ··········
M.G.S/Computer Science/Gr:12/ Term 1/Nov-Dec 2022 \ io

Q.9

The table shows assembly language instructions for a processor which has one general purpose
register, the Accumulator (ACC).

Instruction

Opcode Operand Explanation

LDD <address> Direct addressing. Load contents of given address to ACC


STO <address> Store the contents of ACC at the given address

LDI <address> Indirect addressing. The address to be used is at the given


address. Load the contents of this second address to ACC

Indexed addressing. Form the address from <address> +


LDX <address> the contents of the index register. Copy the contents of this
calculated address to ACC
INC <register> Add 1 to contents of the register (ACC)
JMP <address> Jump to the given address
END
Return control to operating system

The diagram shows the contents of the memory.

Main memory

120 00001001
121 0 1 1 1 0101

122 10 1 1 0 110

123 11100100

124 01111111

125 0000 0001

126 01000001

127

;
0110 1001

200 10001000
22
M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 20 j 11

Trace the assembly language program using the trace table.

300 LDD 321


301 INC
302 STO 323
303 LiJI 307
304 INC
305 STO 322
306 END
307 320

!
320
(
49
321 36
3?? 0
323 0

Trace table:

Memory address
Accumulator "'~'l
, l / .~
'.),' 1 3?.?
J?()

0 0
49 36

'36
'31
37

~9
)C)
5"0

(6)
. ~

M.G.S/Computer Science/Gr:12/Term 1/Nov-Dec 2022 \ i2.


. ' ~ '
010
I A petrol filing station has a single self-eervic:e petrol p1.111p.

A customer can uae the petrol pump when It la ready to dlapense petrol.
The pump is in use when the customer takes the nozzle from a holster on the pump.
The pump dispenses petrol while the customer preasee the trigger on the nozzle.
When the customer replaces the nozzle into the holster, the pump is out of use.
The cashier must press a reset button to make the pump ready for the next customer to use.
The petrol pump's four poaalble etatH and the tranaltlon from one state to another are as shown in
the table below.

Current state Event Next state


Pump ready Take nozzle Pump In use
Pump in use Pl'888 trigger Pump dispensing
Pump dispensing Stop preasing trigger Pump in use
Pump in use Replace nozzle Pump out of UN
Pump out of use Reset pump chplay Pump ready

Complete the state tranaltlon diagram for the patrol pump:

[4)

You might also like