20r.t.
r6
Time:2 hrs.
SUBJECT: ComprEr Applications s - rx(rcsE Max. Mark:90
This paper is divided i to two sedions. Attempt all questions from Section A and any four from SeEtion B. The first 15 minutes
are given as reading time. The above given time is the time writing time.
Section A (:ltl Markrl
Attempt all the questions. lro noi sp€nd more than 50 mioutes to solve this section
Questlon 1 Study the given code and solve the questions below it
tur(int i=1;i<=10;i+=1)
System.out.print((i+I)};
System.out.println("ENDr);
i) Namethe loop controlling variable h, 6.f I2I
ii) What belongs to the body ofthe loop? \ tzl ...
iii) ldentirythe test condition I2l /
iv)What is the fi6tralue shown when the Ioop is executed?t lrl
v) The line System.out.print("END/) is outside the loop or is ita partofthe body'? give a Fason t2t
l
to Support yoqr answer
Define the following ts\ q
',1 t8l
alDanglingelse b) Exit conrolled loop c) lnfinfte loop d) Type promotlon
t,
Qrresdon 3 a) What are floating literals ? give examples t2t
b) What will b€ the output after the following;xp.ession is evaluated , if x=5 t2l
(
system.out.print(r++ '2+3'-x) = 6 v?+3'
c) What will be the output , wien *le below \6lues a.e receiued in the given below code
i, Th€ \ralue entered for num i5 4 l2l
li) The value entered for nfin is 6 t2!
r switch(num)
{ case 6: System.out.pint("sDe};
break;
case 7: nurl}}+;
SystemouLprint(num);
case 4 : ++num;
num'=2;
System.out.print(nulri];
Quenlon 4 a) Rewrite the following statement in its equi\ralent ternary operator t2t
if {D=so)
c=x+10;
else
c--x-10;
b) What is the size of the primitive type char and what is its initial value I2I
Section B (50 Mar*s)
(Attempt any tour questions. Each carfies 15 marb.)
Do notsp€nC rnoit"i,*ftE mtnui.sriiffdi:i$iit'iiE
qrest'ron 5. The electricity board charges bill depending on the units consumed by the consumer accoiding to the '
Ilsl
following criteria
units Rate
First 1OO units 1.4O perunit
Next 200 units 2 rupee per unit
Next 30O units 2.50 per unit
Write a program to accept consuher name ? unfu con med. Also caldilate the net bill adding a rent of
rupees 250 to it as meter ahar8e for every @nsumer . After cakulation display the 6ollowing slip
NAMT UNITSCONSUMED NfT BIT.L
qqestion 5. Write a menu driven proSram to corwert temperdture for Fahaenheit to Celsius and vice veBa. For an [151
incorrect choice show the message 'WROI!6 ENTRY "
-lbe,_iofpd$.r6sr-----G.lsius5/9't+ahrenheiL32}-*.:
Fahrenheit -1.8.Celsir6 +32
Question 7. Writq,a program to accept a numb€r a nd cherk if it is an Aamstrong number [1sl
Armstrong number is one when sum of the otbe of tlle digits of the number are equal to the number
itsen
e.g 153 = 13153+33
question L a) Write a program to accept 15 numbers, find their average and also show the maimu;value t7l
b) Write a prcBram to acept a number and check if it is a prime numb€r or not. Show poper me$ages [gl
Question 9. Write sepa rate programs for ea€h subpa rt to show the respective s€rbs
FJ' . al Sfiow the first 10 elemenrs ofthe;d;ies 1, 9 , zs, 49 ......... l4
b) Showth€ sum 2+ 4+ 6+8--n I4