Class 12 CS 083 Previous Year Question Paper 2019 – Solution

Series BVM
Question Paper Code 91 Set 4

COMPUTER SCIENCE – SOLUTION UPDATING…
(Session 2018-19)

Time allowed : 3 hours

Maximum Marks : 70

General Instructions :

  1. SECTION A refers to programming language C++.
  2. SECTION B refers to programming language Python.
  3. SECTION C is compulsory for all.
  4. Answer either SECTION A or SECTION B.
  5. It is compulsory to mention on the page 1 in the answer-book whether you are attempting SECTION A or SECTION B.
  6. All questions are compulsory within each section.
  7. Questions 2(b), 2(d), 3 and 4 have internal choices.

SECTION A
[Only for candidates, who opted for C++]

1. (a) Write the names of any four fundamental data types of C++.
Answer: (i) int, (ii) float, (iii) double, (iv) char

(b) Write the names of the correct header files, which must be included in the following C++ code to compile the code successfully :
void main()
{
char L[]="CS 2018";
int N=strlen(L);
cout<<L[N-1];
}

Answer:
#include <iostream>
#include <cstring>

(c) Rewrite the following C++ program after removing any/all syntactical error(s). Underline each correction done in the code :
Note : Assume all required header files are already included in the program.
#define Area(L,B) = L*B
structure Recta
{
int Length,Breadth;
};
void main()
{
Recta R = [10,15];
cout<<Area(Length.R,Breadth.R);
}

#define Area(L, B) (L * B)

struct Recta
{
    int Length, Breadth;
};

int main()
{
    Recta R = {10, 15};
    cout << Area(R.Length, R.Breadth);
    return 0;
}

1. Removed the equals sign after #define Area(L,B).
2. Changed structure to struct.
3. Used curly braces {} to initialize Recta R.
4. Changed void main() to int main() and added return 0; at the end.
5. Corrected the usage of Length and Breadth members of the Recta struct in the cout statement.

(d) Find and write the output of the following C++ program code :
Note : Assume all required header files are already included in the program.
void Alter(char *S1, char *S2)
{
char *T;
T=S1;
S1=S2;
S2=T;
cout<<S1<<"&"<<S2<<end1;
}
void main ()
{
char X[]="First", Y[]="Second";
Alter(X,Y);
cout<<X<<"*"<<Y<<end1;
}

Answer: The output will be:
Second&First
First*Second

(e) Find and write the output of the following C++ program code :
Note : Assume all required header files are already included in the program.
void Convert(float &X, int Y=2)
{
X=X/Y;
Y=X+Y;
cout<<X<<"*"<<Y<<endl;
}
void main()
{
float M=15, N=5;
Convert(M,N);
Convert(N);
Convert(M);
}

Answer: The output will be:
7.5*10
2.5*5
1.25*4

(f) Observe the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the minimum and maximum values that can possibly be assigned to the variable End.
Note : Assume all the required header files are already being included in the code.
The function random(N) generates any possible integer between 0 and N-1 (both values included).
void main()
{
randomize();
int A[]={10,20,30,40,50,60,70,80};
int Start = random(2) + 1;
int End = Start + random(4);
for(int I=Start; I<=End; I++)
cout<<A[I]<<"$";
}

Class 12 CS 083 Previous Year Question Paper 2019 Q.1f
Answer: (ii) 20$30$40$50$60$

2. (a) Given the following class Test and assuming all necessary header file(s) included, answer the questions that follow the code :
Class 12 CS 083 Previous Year Question Paper 2019 Q.2a
(i) Which of the statement(s) out of (I), (II), (III), (IV) is/are incorrect for object(s) of the class Test ?
(ii) What is Function 4 known as ? Write the Statement IV, that would execute Function 4.

(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.
Class 12 CS 083 Previous Year Question Paper 2019 Q.2b
(i) For the class Point, what is Function 3 known as ? When is it executed ?
(ii) What is the output of the above code, on execution ?
OR
(b) Explain Polymorphism in context of Object Oriented Programming. Also give a supporting example in C++.

(c) Write the definition of a class GRAPH in C++ with following description :
Class 12 CS 083 Previous Year Question Paper 2019 Q.2c

(d) Answer the questions (i) to (iv) based on the following :
class Ground
{
int Rooms;
protected:
void Put();
public:
void Get();
};
class Middle : private Ground
{
int Labs;
public:
void Take();
void Give();
};
class Top : public Middle
{
int Roof;
public:
void In();
void Out();
};
void main()
{
Top T;
}

(i) Which type of Inheritance out of the following is illustrated in the above example ?
– Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
(ii) Write the names of all the members, which are directly accessible by the member function Give() of class Middle.
(iii) Write the names of all the members, which are directly accessible by the member function Out() of class Top.
(iv) Write the names of all the members, which are directly accessible by the object T of class Top declared in the main() function.

OR

(d) Consider the following class HeadQuarter
class HeadQuarter
{
int Code;
char Des[20];
protected :
char Address[40];
public:
void Get(){cin>>Code;gets(Des);gets(Address);}
void Put(){cout<<Code<<Des<<Address<<endl;}
};

Write a code in C++ to protectedly derive another class FrontOffice from the base class HeadQuarter with following members.
Data Members
– Location of type character of size 10
– Budget of type double
Member Functions
– A constructor function to assign Budget as 100000
– Assign() to allow user to enter Location and Budget
– Display() to display Location and Budget

3. (a) Write a user-defined function NoTwoThree(int Arr[], int N) in C++, which should display the value of all such elements and their corresponding locations in the array Arr (i.e. the array index), which are not multiples of 2 or 3N represents the total number of elements in the array Arr, to be checked.
Example : If the array Arr contains
Class 12 CS 083 Previous Year Question Paper 2019 Q.3a

OR

Write a user-defined function ReArrange(int Arr[], int N) in C++, which should swap the contents of the first half locations of the array Arr with the contents of the second half locations. N (which is
an even integer) represents the total number of elements in the array Arr.
Class 12 CS 083 Previous Year Question Paper 2019 Q.3aOR

(b) Write definition for a function XOXO(char M[4][4]) in C++, which replaces every occurrence of an X with an O in the array, and vice versa.
For example :
Class 12 CS 083 Previous Year Question Paper 2019 Q.3b

OR

(b) Write definition for a function ColSwap(int A[4][4]) in C++, which swaps the contents of the first column with the contents of the third column.
For example :
Class 12 CS 083 Previous Year Question Paper 2019 Q.3bOR

(c) Let us assume P[20][10] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes, find the address of the element P[10][5], if the address of the element P[5][2] is 25000.

OR

(c) Let us assume P[20][30] is a two-dimensional array, which is stored in the memory along the column with each of its elements occupying 2 bytes. Find the address of the element P[5][6], if the base address of the array is 25000.

(d) Write a user-defined function Pop(Book B[], int &T), which pops the details of a Book, from the static stack of Book B, at the location T (representing the Top end of the stack), where every Book of the stack is represented by the following structure :
struct Book
{
int Bno;
char Bname[20];
};


OR

(d) For the following structure of Books in C++
struct Book
{
int Bno;
char Bname[20];
Book *Link;
};

Given that the following declaration of class BookStack in C++ represents a dynamic stack of Books :
Class 12 CS 083 Previous Year Question Paper 2019 Q.3dOR

Write the definition for the member function void BookStack::Push(), that pushes the details of a Book into the dynamic stack of BookStack.

(e) Evaluate the following Postfix expression, showing the stack contents :
250,45,9,/,5,+,20,*,-

OR

(e) Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion :
A + B * C ^ D - E

4. (a) A text file named MESSAGE.TXT contains some text. Another text file named SMS.TXT needs to be created such that it would store only the first 150 characters from the file MESSAGE.TXT.
Write a user-defined function LongToShort() in C++ that would perform the above task of creating SMS.TXT from the already existing file MESSAGE.TXT.

OR

(a) A text file named CONTENTS.TXT contains some text. Write a user-defined function LongWords() in C++ which displays all such words of the file whose length is more than 9 alphabets. For example : if the file CONTENTS.TXT contains :
"Conditional statements of C++ programming language are if and switch"
Then the function LongWords() should display the output as :
Conditional
statements
programming


(b) Write a user-defined function TotalPrice() in C++ to read each object of a binary file STOCK.DAT, and display the Name from all such records whose Price is above 150. Assume that the file STOCK.DAT is created with the help of objects of class Stock, which is defined below :
Class 12 CS 083 Previous Year Question Paper 2019 Q.4b

OR

(b) A binary file DOCTORS.DAT contains records stored as objects of the following class :
Class 12 CS 083 Previous Year Question Paper 2019 Q.4bOR
Write definition for function Details(int N) in C++, which displays the details of the Doctor from the file DOCTORS.DAT, whose DNo matches with the parameter N passed to the function.

(c) Find the output of the following C++ code considering that the binary file STOCK.DAT exists on the hard disk with the following 5 records for the class STOCK containing Name and Price.
Class 12 CS 083 Previous Year Question Paper 2019 Q.4c

OR

(c) Differentiate between seekg() and tellg().

SECTION B
[Only for candidates, who opted for Python]

1. (a) Write the names of any four data types available in Python.

(b) Name the Python Library modules which need to be imported to invoke the following functions :
(i) sqrt()
(ii) start()


(c) Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.
250 = Number
WHILE Number<=1000:
if Number=>750:
print Number
Number=Number+100
else
print Number*2
Number=Number+50


(d) Find and write the output of the following python code :
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print Msg3


(e) Find and write the output of the following python code :
def Changer(P,Q=10):
P=P/Q
Q=P%Q
print P,"#",Q
return P
A=200
B=20
A=Changer(A,B)
print A,"$",B
B=Changer(B)
print A,"$",B
A=Changer(A)
print A,"$",B


(f) What possible output(s) are expected to be displayed on screen at the time of execution of the program from the following code ? Also specify the minimum values that can be assigned to each of the variables BEGIN and LAST.
Class 12 CS 083 Previous Year Question Paper 2019 Sec-B-Q.1f

2. (a) Write four features of object oriented programming.
Class 12 CS 083 Previous Year Question Paper 2019 Sec-B-Q.2b
Write the output of the above Python code.

OR

Class 12 CS 083 Previous Year Question Paper 2019 Sec-B-Q.2bOR
(i) What are the methods/functions mentioned in Line 2 and Line 7 specifically known as ?
(ii) Mention the line number of the statement, which will call and execute the method/function shown in Line 2.

(c) Define a class HOUSE in Python with the following specifications :
Class 12 CS 083 Previous Year Question Paper 2019 Sec-B-Q.2c

(d) Answer the questions (i) to (iii) based on the following :
Class 12 CS 083 Previous Year Question Paper 2019 Sec-B-Q.2d
(i) Write the type of the inheritance illustrated in the above.
(ii) Find and write the output of the above code.
(iii) What is the difference between the statements shown in Line 11 and Line 12 ?

OR

(d) Define inheritance. Show brief python example of Single Level, Multiple and Multilevel Inheritance.

Find Class 12 Computer Science Previous Year Question Papers

Find Class 12 Computer Science Previous Year Question Papers Solution

Find Class 12 Computer Science Previous Year Compartment Question Papers

Find Class 12 Computer Science Previous Year Compartment Question Papers Solution

Leave a Comment