CBSE Class 12 Computer Science Marking Scheme Question Paper 2018-19
CBSE Class 12 Computer Science Marking Scheme Question Paper 2018-19
Marking Scheme
COMPUTER SCIENCE (Code: 083)
CLASS:-XII
Time:3 Hrs. M.M.:70
Q. No. Part Question Description Marks
1 (a) Write the type of C++ Operators (Arithmetic, Logical, and Relational 2
Operators) from the following:
(b) Observe the following program very carefully and write the name of those 1
header file(s), which are essentially needed to compile and execute
m
thefollowing program successfully:
void main()
{
co
char text[20], newText[20];
gets(text);
strcpy(newText,text);
a.
for(int i=0;i<strlen(text);i++)
if(text[i]==’A’)
di
text[i]=text[i]+2;
puts(text);
}
rin
Ans. stdio.h
string.h
e
(c) Rewrite the following C++ code after removing any/all Syntactical Error(s) (2)
with each correction underlined.
.c
Note: Assume all required header files are already being included in the
program.
w
{
float R=4.5,H=1.5;
w
A=2*PI*R*H + 2*PIpow(R,2);
cout<<‘Area=’<<A<<endl;
}
1
#define PI 3.14//Error 1
void main( )
{
float R=4.5,H=1.5;
floatA=2*PI*R*H + 2*PI*pow(R,2); //Error 2, 3
cout<<“Area=”<<A<<endl; //Error 4
}
(d) Find and write the output of the following C++ program code: (3)
Note: Assume all required header files are already being included in
the program.
void main( )
{
int Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
int *Ptr = Ar , I ;
cout<<++*Ptr++ << '@' ;
m
I = Ar[3] - Ar[2] ;
cout<<++*(Ptr+I)<<'@'<<"\n" ;
co
cout<<++I + *Ptr++ << '@' ;
cout<<*Ptr++ <<'@'<< '\n' ;
for( ; I >=0 ; I -=2)
cout<<Ar[I] << '@' ;
a.
}
di
Ans 7@11@
6@8@
rin
11@3@
Note:
Deduct only ½ Mark for not considering any or all correct placements of
@
a
Deduct only ½ Mark for not considering any or all line break
.c
(e) Find and write the output of the following C++ program code: (2)
typedef char STRING[80];
w
void MIXNOW(STRING S)
{
w
int Size=strlen(S);
for(int I=0;I<Size;I+=2)
w
{
char WS=S[I];
2
S[I]=S[I+1];
S[I+1]=WS;
}
for (I=1;I<Size;I+=2)
if (S[I]>=’M’ && S[I]<=’U’)
S[I]=’@’;
}
void main()
{
STRING Word=”CBSEEXAM2019”;
MIXNOW(Word);
cout<<Word<<endl;
}
Ans. BCE@XEMA0291
m
(f) Observe the following program and find out, which output(s) out of (i) to (2)
co
(iv) willbe expected from the program? What will be the minimum and the
maximum value assigned to the variable Alter?
Note: Assume all required header files are already being included in
the program.
a.
void main( )
{
di
randomize();
int Ar[]={10,7}, N;
rin
int Alter=random(2) + 10 ;
for (int C=0;C<2;C++)
{
N=random(2) ;
e
cout<<Ar[N] +Alter<<”#”;
re
}
}
(i) 21#20# (ii) 20#18#
a
3
2 (a) What is a copy constructor? Illustrate with a suitable C++ example. (2)
3
Ans. A copy constructor is an overloaded constructor in which an object of the
same class is passed as reference parameter.
class X
{
int a;
public:
X()
{
a=0;
}
X(X &ob) //copy constructor
{
a=ob.a;
}
};
m
OR
co
(1 Mark for correct explanation of copy constructor only without an
example)
a.
(b) Write the output of the following C++ code. Also, write the name of (2)
feature of Object Oriented Programming used in the following program
di
jointly illustrated by the Function 1 to Function 4.
rin
}
re
cout<<end1 ;
.c
}
void My_fun (int A, int B) // Function 3
{
w
}
void My_fun (char T, int N) // Function 4
w
{
for (int I=1 ; I<=N ; I++) cout<<T ;
cout<<end1;
4
}
void main ( )
{
int X=7, Y=4, Z=3;
char C='#' ;
My_fun (C,Y) ;
My_fun (X,Z) ;
}
OR
Ans. ####
71421
Polymorphism
OR
Function Overloading
m
OR
Constructor Destructor
co
Name of the constructor function is Name of the destructor function is
same as that of class same as that of class preceded by
~
a.
Constructor functions are called Destructor functions are called
automatically at the time of automatically when the scope of
creation of the object the object gets over
di
Constructor can be overloaded Destructor ca not be overloaded
Constructor is used to initialize the Destructor is used to de- initialize
rin
OR
(c) Define a class Ele_Bill in C++ with the following descriptions: (4)
Private members:
Cname of type character array
w
amount asNo_of_units*Cost .
5
Amount can be calculated accordingto the following conditions:
No_of_units Cost
Public members:
Ans.
class Ele_Bill
{
char Cname[20];
m
long Pnumber;
int No_of_units;
float Amount;
co
void Calc_Amount( );
public:
void Accept();
a.
void Display();
};
di
if(No_of_units<=50)
{
Amount=0;
e
}
else if(No_of_units<=150)
re
{
Amount=(No_of_units-50)*0.80;
a
}
else if(No_of_units<=350)
.c
{
Amount=80+(No_of_units-150)*1.00;
w
}
else
w
{
Amount=80+200+(No_of_units-350)*1.20;
w
}
}
void Ele_Bill :: Accept( )
6
{
gets(Cname);
cin>Pnumber>>No_of_units;
Calc_Amount( );
}
void Ele_Bill :: Display( )
{
cout<<Cname<<Pnumber<<No_of_units<<Amount;
}
m
Marks to be awarded for defining the member functions inside or
outside the class
co
(d) Answer the questions (i) to (iv) based on the following: (4)
class Faculty
{
a.
int FCode;
protected:
di
char FName[20];
public:
rin
Faculty();
void Enter();
void Show();
};
e
class Programme
re
{
int PID;
protected:
a
char Title[30];
public:
.c
Programme();
void Commence();
w
void View();
};
w
int DD,MM,YYYY;
public:
Schedule();
7
void Start();
void View();
};
void main()
{
Schedule S; //Statement 1
___________ //Statement 2
}
OR
m
Write a code in C++ to publically derive another class ‘District’
with the following additional members derived in the public
co
visibility mode.
Data Members :
Dname string
Distance float
a.
Population long int
Member functions :
di
DINPUT( ) : To enter Dname, Distance and population
DOUTPUT( ) : To display the data members on the screen.
rin
(i) Write the names of all the member functions, which are directly accessible
by the object S of class Schedule as declared in main() function.
e
(ii) Write the names of all the members, which are directly accessible by the
memberfunction Start( ) of class Schedule.
w
8
NOTE:
Marks not to be awarded for partially correct answer
Ignore the mention of Constructors
(iii) Write Statement 2 to call function View( ) of class Programme from the
object S of class Schedule.
Ans. S.Programme::View( );
(iv) What will be the order of execution of the constructors, when the object S
of class Schedule is declared inside main()?
OR
Ans. class District : public State
{
public :
m
char Dname[20];
float Distance;
co
long int Population;
void DINPUT( )
{
gets(Dname);
a.
cin>>distance;
cin>>Population;
di
}
void DOUTPUT( )
rin
{
cout<<Dname<<endl;
cout<<Distance<<endl;
cout<<population<<endl;
e
}
re
};
(1 Mark for writing correct order)
a
OR
w
Population)
(1 Mark for defining the function DINPUT( ) )
(1 Mark for defining the function DOUTPUT( ) )
9
(a) Write a user-defined function AddEnd4(int A[][4],int R,int C) in C++ to (2)
Ans. find and display the sum of all the values, which are ending with 4 (i.e.,
unit place is 4).
For example if the content of array is:
24 16 14
19 5 4
The output should be 42
OR
Write a user defined function in C++ to find the sum of both left and right
diagonal elements from a two dimensional array.
m
sum=sum+A[I][J];
}
co
cout<<sum;
} a. OR
void Diagsumboth(int A[][4], int n)
{
di
int sumLt=0,sumRt=0;
for(int i=0;i<n;i++)
rin
{
sumLt+=A[i][i];
else
sumRt+=A[n-1-i][i];
e
}
cout<<”sum of left diagonal”<<sumlt<<endl;
re
OR
(1/2 Mark for correct loop)
w
10
(b) Write a user-defined function EXTRA_ELE(int A[ ], int B[ ], int N) in C++ (3)
to find and display the extra element in Array A. Array A contains all the
elements of array B but one more element extra. (Restriction: array
elements are not in order)
OR
m
{
for(j=0;j<N;j++)
{
co
if(A[i]==B[j])
{
flag=1;
a.
break;
}
di
}
if(flag==0)
cout<<"Extra element"<<A[i];
rin
flag=0;
}
}
e
OR
re
int temp;
for(int i=0;i<n/2;i++)
.c
{
temp=A[i];
w
A[i]=A[n-1-i];
A[n-1-i]=temp;
w
}
}
w
11
OR
(1 Mark for correct loop)
(2 Marks for swapping elements)
(c) An array S[10] [30] is stored in the memory along the column with each of (3)
its element occupying 2 bytes. Find out the memory location of S[5][10], if
element S[2][15] is stored at the location 8200.
OR
An array A[30][10] is stored in the memory with each element requiring 4
bytes of storage ,if the base address of A is 4500 ,Find out memory
locations of A[12][8], if the content is stored along the row.
Ans. OPTION 1:
ASSUMING LBR=LBC=0
W=2 BYTES, NUMBER OF ROWS(M)=10, NUMBER OF
COLUMNS(N)=30
LOC(S[I][J]) = B +(I + J*M)*W
LOC(S[2][15]) = B +(2+15*10)* 2
m
8200 = B + (152*2)
B = 8200 - 304
co
B = 7896
LOC(S[5][10]) = 7896 +(5+10*10)* 2
= 7896 + (105*2)
= 7896 + 210
a.
= 8106
di
OPTION 2:
ASSUMING LBR=2,LBC=15 AND B = 8200
rin
= 8200 + (3 + (-5)*10) * 2
re
= 8200 + (3 + (-50)) * 2
= 8200 + (3 – 50) * 2
= 8200 + (-47) * 2
a
= 8200 – 94
.c
= 8106
OR
w
=4500+4*(10*12+8)
= 4500 4*(128)
w
=4500 + 512
= 5012
12
1 Mark for writing correct formula (for column major)
OR substituting formula with correct values)
(1 Mark for correct step calculations)
(1 Mark for final correct address)
OR
(d) Write the definition of a member function Ins_Player() for a class (4)
CQUEUE in C++, to add a Player in a statically allocated circular queue of
PLAYERs considering the following code
is already written as a part of the program:
struct Player
{
long Pid;
m
char Pname[20];
};
co
const int size=10;
class CQUEUE
{
Player Ar[size];
a.
int Front, Rear;
public:
di
CQUEUE( )
{
rin
Front = -1;
Rear=-1;
}
void Ins_Player(); // To add player in a static circular queue
e
OR
.c
{
int BNo;
w
char BName[20];
Book *Next;
};
13
Ans. void CQUEUE : : Ins_Player( )
{
if((Front==0 && Rear==size-1) || (Front==Rear+1)
{
cout<< “Overflow”;
return;
}
else if(Rear = = -1)
{
Front=0;
Rear=0;
}
else if(Rear= =size-1)
{
Rear=0;
}
else
{
Rear++;
}
m
cout<< “Enter Player Id=”;
cin>>Ar[Rear].Pid;
cout<< “Enter Player Name=”;
co
gets(Ar[Rear].Pname);
}
a.
OR
di
struct Book
{
rin
int BNo;
char BName[20];
Book *Next;
}*temp,*top;
e
re
void pop()
{
a
temp=new Book ;
temp=top;
.c
top=top->next;
delete temp;
w
}
w
(e) Convert the following Infix expression to its equivalent Postfix expression, (2)
showing the stack contents for each step of conversion.
A/B+C*(D-E)
OR
Evaluate the following Postfix expression :
4,10,5,+,*,15,3,/,-
Ans:
Element Stack Postfix
A A
/ / A
B / AB
+ + AB/
m
C + AB/C
* +* AB/C
co
( +*( AB/C
D +*( AB/CD
- +*(- AB/CD
a.
E +*(- AB/CDE
) +* AB/CDE-
di
+ AB/CDE-*
AB/CDE-*+
OR
rin
55
OR
re
4 (a) Write a function RevText() to read a text file “ Input.txt “ and Print only (2)
.c
OR
w
15
Ans. void RevText( )
{
ifstream Fin(“Input.txt”);
char Word[20];
while(!Fin.eof())
{
Fin>>Word;
if(Word[0]==’I’)
strrev(Word);
cout<<Word<< “ ”;
}
Fin.close( );
}
OR
int Countalpha()
ifstream ifile ("BOOK.txt");
char ch;
int count =0;
m
while (! ifile.eof())
{
co
ifile.get(ch);
if(isfower(ch))
count ++;
}
a.
ifile.close();
return (count)
di
}
rin
OR
a
(b) Write a function in C++ to search and display details, whose destination is (3)
w
class BUS
{ int Bno; // Bus Number
char From[20]; // Bus Starting Point
16
char To[20]; // Bus Destination
public:
char * StartFrom ( ); { return From; }
char * EndTo( ); { return To; }
void input() { cin>>Bno>>; gets(From); get(To); }
void show( ) { cout<<Bno<< “:”<<From << “:” <<To<<endl; }
};
OR
Write a function in C++ to add more new objects at the bottom of a binary
file "STUDENT.dat", assuming the binary file is containing the objects of
the following class :
class STU
{
int Rno;
char Sname[20];
public: void Enter()
{
cin>>Rno;gets(Sname);
}
m
void show()
{
co
count << Rno<<sname<<endl;
}
};
a.
Ans. void Read_File( )
{
di
BUS B;
ifstream Fin;
Fin.open(“Bus.Dat”, ios::binary);
rin
{
re
B.show( ) ;
}
}
a
Fin.close( );
}
.c
OR
void Addrecord()
w
{
ofstream ofile;
w
char ch='Y';
while (Ch=='Y' || Ch = = 'y')
{
17
S.Enter();
ofile.write (Char*) & S, sizeof(s));
cout << "more (Y/N)";
cin>>ch;
}
ofile.close();
}
OR
(c) Find the output of the following C++ code considering that the binary file (1)
m
PRODUCT.DAT exists on the hard disk with a list of data of 500 products.
class PRODUCT
co
{
int PCode;char PName[20];
public:
a.
void Entry();void Disp();
};
void main()
di
{
fstream In;
rin
In.open("PRODUCT.DAT",ios::binary|ios::in);
PRODUCT P;
In.seekg(0,ios::end);
cout<<"Total Count: "<<In.tellg()/sizeof(P)<<endl;
e
In.seekg(70*sizeof(P));
re
In.read((char*)&P, sizeof(P));
In.read((char*)&P, sizeof(P));
cout<<"At Product:"<<In.tellg()/sizeof(P) + 1;
a
In.close();
.c
}
OR
w
OR
18
fstream/ ifstream
OR
(1 Mark for correct stream)
5 (a) Observe the following table and answer the parts(i) and(ii) accordingly (2)
Table:Product
(i) Write the names of most appropriate columns, which can be considered as
m
candidate keys.
co
Ans. Candidate Key: Pno, Name
(b) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (4+2)
re
TRAINER
.c
19
COURSE
(i) Display the Trainer Name, City & Salary in descending order of their
Hiredate.
m
(ii) To display the TNAME and CITY of Trainer who joined the Institute in the
month of December 2001.
co
Ans. SELECT TNAME, CITY FROM TRAINER WHERE HIREDATE
BETWEEN ‘2001-12-01’ AND ‘2001-12-31’;
a.
OR
SELECT TNAME, CITY FROM TRAINER WHERE HIREDATE >=
‘2001-12-01’ AND HIREDATE<=‘2001-12-31’;
di
OR
SELECT TNAME, CITY FROM TRAINER WHERE HIREDATE LIKE
rin
‘2001-12%’;
(½ Mark for
WHERE HIREDATE BETWEEN ‘2001-12-01’ AND ‘2001-12-31’
re
OR
WHERE HIREDATE >= ‘2001-12-01’ AND HIREDATE<=‘2001-12-31
OR
a
TRAINER and COURSE of all those courses whose FEES is less than or
equal to 10000.
w
FEES<=10000;
20
(1 Mark for correct query)
OR
(½ Mark for correct SELECT )
(½ Mark for correct WHERE Clause)
Ans. TIDTNAME
103 DEEPTI
106 MANIPRABHA
m
(½ Mark for correct output)
co
(vi) SELECT DISTINCT TID FROM COURSE;
Ans. TIDCOUNT(*)MIN(FEES)
101 2 12000
a
STARTDATE< ‘2018-09-15’;
w
Ans. COUNT(*)SUM(FEES)
4 65000
w
21
6 (a) State any one Distributive Law of Boolean Algebra and Verify it using (2)
truth table.
OR
A(B+C)=AB+AC
m
A B C B+C A(B+C) AB AC AB+AC
0 0 0 0 0 0 0 0
co
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
a.
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
di
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
rin
(b) Draw the Logic Circuit of the following Boolean Expression: (2)
re
Ans.
.c
w
w
w
(c) Derive a Canonical SOP expression for a Boolean function F(X,Y,Z) (1)
represented by the following truth table:
22
X Y Z F(X,Y,Z)
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
m
(d) Reduce the following Boolean Expression to its simplest form using K- (3)
co
Map:
F(X,Y,Z,W)= (0,1,2,3,4,5,8,10,11,14)
a.
di
e rin
(½ Mark for drawing K-Map and correctly plotting 1s in the given cells)
( ½ Mark each for 4 groupings)
a
Note:
Deduct ½ mark if wrong variable names are used
w
7 (a) Arun opened his e-mail and found that his inbox was full of hundreds of (2)
unwanted mails. It took him around two hours to delete these unwanted
w
mails and find the relevant ones in his inbox. What may be the cause of his
receiving so many unsolicited mails? What can Arun do to prevent this
w
happening in future?
23
Ans. Arun’s email has been attacked with spam.
These may be promotional mails from different advertisement groups.
Arun must have checked some promotional offers while surfing the
Internet.
He should create filters in his email to stop receiving these unwanted mails.
(b) Assume that 50 employees are working in an organization. Each employee (1)
has been allotted a separate workstation to work. In this way, all computers
are connected through the server and all these workstations are distributed
over two floors. In each floor, all the computers are connected to a switch.
Identify the type of network?
(c) Your friend wishes to install a wireless network in his office. Explain him (1)
m
the difference between guided and unguided media.
co
Ans. Guided media uses cables to connect computers, whereas unguided media
uses waves. a.
(1 Mark for writing any correct difference between guided and unguided
media)
di
(d) Write the expanded names for the following abbreviated terms used in (2)
Networkingand Communications:
rin
wings
namedasSENIOR(S),JUNIOR(J),ADMIN(A)andHOSTEL(H).
w
w
24
SENIOR JUNIOR
ADMIN HOSTEL
m
WingAtoWingS 100m
co
WingAtoWingJ 200m
WingAtoWingH
a. 400m
WingStoWingJ 300m
WingStoWingH 100m
di
WingJtoWingH 450m
rin
Wings NumberofComputers
e
WingA 20
re
WingS 150
a
WingJ 50
.c
WingH 25
w
(i) Suggest the best wired medium and draw the cable layout to efficiently
connect various wings of Multipurpose PublicSchool, Bangluru.
w
25
SENIOR
JUNIOR
ADMIN HOSTEL
m
(ii) Name the most suitable wing where the Server should be
installed. Justify your answer.
co
Ans. Wing Senior(S)- Because it has maximum number of computers.
(iv) Suggest a device and the protocol that shall be needed to provide wireless
a
Modem OR RFTransmitter
Protocol : WAP OR 802.16 OR TCP/IP OR VOIP OR MACP OR 802.11
w
26