XII/CS(283)/FRAGMENT-2-EXAM. PAGE 1 OF 18 MARKING SCHEME FRAGMENT-2 EXAMINATION(2019-20) CLASS-XII SUBJECT: COMPUTER SCIENCE(283) TIME: 3 Hrs M.MARKS:70 General Instructions: (a) All questions are compulsory. (b) Programming Language : C++ (c) Read the questions before writing answers. 1 a) What is the output of this program? Select the correct option. #include <iostream.h> void main() { intarr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout<<arr; } A. 4,5,6,7 B. 5 C. address of 4 D. 7 1 Answer: C. address of 4 1 Mark for correct option b) Which of the following declaration(s) are illegal? A. char *str[ ]={“hello”}; B. char *str = “hello”; C. char str = “hello”; D. char *str=[“hello”]; 1 Answer: C. char str = “hello”; D.char *str=[“hello”]; ½ Mark for each correct option c) Give difference between the following: i) int *n=new int(5); ii) int *n=new int[5]; 1 Answer: In i) case n pointer address is initialized by value 5 where as in ii) array of 5 integer pointers is created and represented by n. 1 Mark for correct difference
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 1 OF 18
MARKING SCHEME
FRAGMENT-2 EXAMINATION(2019-20)
CLASS-XII
SUBJECT: COMPUTER SCIENCE(283)
TIME: 3 Hrs M.MARKS:70 General Instructions:
(a) All questions are compulsory.
(b) Programming Language : C++
(c) Read the questions before writing answers.
1 a) What is the output of this program? Select the correct option.
#include <iostream.h>
void main()
{
intarr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout<<arr;
}
A. 4,5,6,7
B. 5
C. address of 4
D. 7
1
Answer: C. address of 4
1 Mark for correct option
b) Which of the following declaration(s) are illegal?
A. char *str[ ]={“hello”};
B. char *str = “hello”;
C. char str = “hello”;
D. char *str=[“hello”];
1
Answer: C. char str = “hello”;
D.char *str=[“hello”];
½ Mark for each correct option
c) Give difference between the following:
i) int *n=new int(5);
ii) int *n=new int[5];
1
Answer: In i) case n pointer address is initialized by value 5 where as
in ii) array of 5 integer pointers is created and represented by n.
1 Mark for correct difference
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 2 OF 18
½ Mark for only explaining one part
d) Find the output of the following program :
#include<iostream.h>
void main ( )
{
int X[ ] = {10, 25, 30, 55, 100};
int *p = X ;
while ( *p < 110)
{
if (*p%3!=0)
*p = *p + 1 ;
else
*p = *p + 2 ;
p++;
}
for(int I = 4 ;I>= 1 ;I--)
{
cout<< X[I] << “*” ;
if ( I%3 = = 0) cout<<endl ;
}
cout<<X[0]*3<<endl ;
}
2
Answer: 101*56*
32*26*33
1 Mark for each correct output(line)
½ Mark is deducted if ‘*’ not printed
½ Mark deducted if output is displayed in same line
e) Find and write the output of the following C++ program code
Note: Assume all required header files are already being included in the
program.
void main( )
{
char P[ ]=”google”;
int points[ ]={100,200,101,201};
char *K=P;
int *G=points;
cout<<*K<<”<<”<<*G%4<<endl;
K=K+2;
G+=2;
cout<<K<<”::”<<*G<<endl;
3
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 3 OF 18
*K=*K+1;
*G+=10;
cout<<K<<”==”<<*G;
}
Answer:
g<<0
ogle::101
pgle==111
1 Mark for each correct output(line)
½ Mark deducted if output is displayed in same line
f) Find and write the output of the following C++ program code :
Note : Assume all required header files are already included in the program.
#define Modify(N) N*3+10
void main()
{
int LIST[ ]={10,15,12,17};
int *P=LIST, C;
for(C=3; C>=0; C--)
LIST[C]=Modify(LIST[C]);
for (C=0; C<=3; C++)
{
cout<<*P<<":";
P++;
}
}
2
Answer:
40:55:46:61:
1 Mark for correct output
½ Mark deducted for output without ‘:’
2 a) Write the definition of a member function DeletePacket( ) only, of a class
QUEUE in C++, remove/delete Packet information from a dynamically
allocated QUEUE of Packets considering the following code is already written
as a part of the program.
struct Packet {
int PID;
char Address[20];
Packet *LINK;
4
XII/CS(283)/FRAGMENT-2-EXAM. PAGE 4 OF 18
};
class QUEUE {
Packet *Front, *Rear;
public:
QUEUE( )
{
Front=NULL;
Rear=NULL;
}
void AddPacket( );
void DeletePacket( );
void TRAVERSE( );
~QUEUE();
};
Answer:
void QUEUE ::DeletePacket( )
{
if(Front==NULL)
cout<<”empty”;
else
{
Packet *T=Front;
Front=Front->LINK;
delete T;
T=NULL;
}
}
1 Mark for checking if Queue is Empty
1 Mark for assigning Front to T
1 Mark for changing Front value
1 Mark for deleting T
Marks can be given for any other similar answer
b) Write functions in C++ to perform insert operation in a static circular Queue
containing Book‟s information (represented with the help of an array of