Page 21 - IP
P. 21
CBSE AISSCE 2018 Marking Scheme for Informatics Practices
(Sub Code: 065 Paper Code 90)
Ans Variable ‘c’ cannot be of float/real data type.
Note: Full 1 mark should be allotted if correct code is written
(1 mark for identifying/ correcting the code)
(b) What will be displayed in JOptionPane when the following code is executed?
int a=5, b = 2; 2
while (a < 20)
{
a = a + b;
b = a - b;
JOptionPane.showMessageDialog(null,a);
}
Ans 7
12
19
31
OR
7 12 19 31
(½ mark for each correct value)
Note : Full 2 marks should be allotted if only 31 is mentioned
(c) Write the code given below using ‘for’ loop instead of ‘while’ loop:
int i=1; 2
while(i<=5)
{
if(i * i == 4)
jTextField1.setText(""+i);
i=i+1;
}
Ans int i;
for(i = 1; i <= 5; i++)
{
if(i * i == 4)
jTextField1.setText(""+i);
}
(½ mark for initialization expression)
(½ mark for test expression)
(½ mark for update expression)
(½ mark body of loop)
(d) Write the value that will be stored in variable a after execution of the following code if: 2
(i) initial value of a is 8.
(ii) initial value of a is 10.
int b = 9;
if (a > b)
a=a+5;
a=a+2;
Page 6 of 13