CBSE Sample Papers for Class 12 Computer Science Paper 2 is part of CBSE Sample Papers for Class 12 Computer Science. Here we have given CBSE Sample Papers for Class 12 Computer Science Paper 2.
CBSE Sample Papers for Class 12 Computer Science Paper 2
Board | CBSE |
Class | XII |
Subject | Computer Science |
Sample Paper Set | Paper 2 |
Category | CBSE Sample Papers |
Students who are going to appear for CBSE Class 12 Examinations are advised to practice the CBSE sample papers given here which is designed as per the latest Syllabus and marking scheme, as prescribed by the CBSE, is given here. Paper 2 of Solved CBSE Sample Paper for Class 12 Computer Science is given below with free PDF download Answers.
Time: 3 Hours
Maximum Marks: 70
General Instructions
- All questions are compulsory within each Section.
- Programming Language in SECTION A : C++.
- Answer the questions after carefully reading the text.
SECTION A
Question 1.
(a) Identify the correct user defined data type out of the following:
(i) int a
(ii) char *p
(iii) class A{….}; A ob 1;
(iv) float & sum;
(v) union stu {…};
(vi) union stu s;
(vii) enum {red, green, blue};
(viii) struct stu{……}
(b) Observe the following C++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C + + compiler.
void main() { int val; cin>>val; if(abs(val)==val) cout<<"Positive"<<endl; }
(c) Rewrite the following program after removing all the syntax error(s), if any. Underline each correction.
#include(iostream.h) void main() { int A[]=(2, 3, 4, 5}, Y; count=Y; cin>>Y; for(i = count-1 ; i>= 0; i--) switch(i) { case 0: case 2: cout<<Y*A[i]<<endl; break; case 1: case 3:cout>>Y+A[i]; } }
(d) What will be the output of the following program?
Note: Assume all required header files are already being included in the program.
class MAIN { public; MAIN() { Calculate(); cout<<"\t"<<"own country\n"; } void Calculate() { display(); cout<<"\t"<<"motherland"; } void display() { cout<<"India is my"; } }; void main() { MAIN m; }
(e) Find and write the output of the following program:
Note: Assume all required header files are already being included in the program.
int a=20; void main() { void func(int &, int, int *); int a=50, b=20; func(a, a, &b); cout<<"\n"<<a<<"\t "<<a<<"\t"<<b; } void func(int &x, int y, int *z) { a + = x; y * = a; *z = a + y; cout<<"\n"<<x<<"\t"<<y<<"\t"<<*z; }
(f) In the following program, if the value of P given by the user is 15, what maximum and minimum values of the variable Guessme, the program could possibly display? And what will be the correct output out of the following options from (i) to (iv)?
Note: Assume all required header files are already being included in the program.
random(n) will generate an integer between 0 and n -1
void main() { int P, Guessme; randomize(); Guessme=random(P)+10; cout<<Guessme<<endl; }
(i) 24
(ii) 34
(iii) 15
(iv) 37
Question 2.
(a) Differentiate between formal parameter and actual parameter with suitable example.
(b) Answer the questions (i) and (ii) after going through the following class:
class SCORE { int Scno, Max, Min, Rank; public: SCORE() // Function1 { Scno = 1; Max = 10; Min = 2; Rank = 5; } SCORE(int a, int b) // Function2 { Scno = a; Max = 10; Min = 2; Rank = b; ~SCORE() // Function3 { cout<<"Compute"< } void Show() // Function4 { cout<<Scno<<":"<<Max<<": "<<Min<<endl; cout<<"Rank"<<Rank<<endl; } };
(i) As per Object-Oriented Programming, which concept is illustrated by Function1 and Function2 together?
(ii) What is Function3 specifically referred as? When do you think, Function3 will be invoked?
(c) Define a class HOTEL in C++ with the following specifications:
(d) Consider the following and answer the questions given below:
class Person { char Pname[25]; protected: char Poffice[25]; public: Person(); char City[25]; void Enter(); void Display(); }; class Man:public Person { long NOM; char Cityname[25]: protected: void Association(); public: Man(); void Add(); void Show(); }; class Children: public Man { char State[25]: public: Children(); void Input(); void Output(); };
(i) Which type of Inheritance is illustrated in the above example?
(ii) How many bytes does an object belonging to class Children require?
(iii) Name of the member functions, which are accessed from the object(s) of class Children.
(iv) Name of the data member(s), which are accessible from the object(s) of class Mem.
Question 3.
(a) Fora 2D array a[4] [4], write a function to prepare a 1D array b[16] that will have all the elements of ‘a’ if they are stored in a row-major form.
e.g. for the following array:
The resultant array should be: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(b) An array A [30] [20] is stored in the memory along with the rowwise with each of the elements occupying 4 bytes. Find out the memory location for the element A[20] [13], if the element A[9] [13] is stored at the memory location 2000.
(c) Write a function in C++ to sort an integer array of 10 elements using selection sort method.
e.g. If array content is
34, 28, 89, 65, 12, 23, 89, 12, 76, 11
The output will be :
11, 12, 12, 23, 28, 34, 65, 76, 89, 89
(d) Convert the following infix expression into postfix. Show the stack status at each step.
True OR False AND NOT False OR False
(e) Write a complete program in C++ to implement a dynamically allocated stack containing names of countries.
Question 4.
(a) Consider a file FILE containing objects of class Student.
(i) Write the statement to place file pointer to the required position.
(ii) Write the statement to add the object S on the binary file.
(b) Write a function in C++ to count the number of uppercase alphabets in a text file.
e.g. If the content of the file UPPERCASE. TXT is as follows:
This is my Book.
You know Ishani.
Delhi is the capital of INDIA.
The function countupper() should display:
(c) Write a function in C++ to read and display the detail of all the customers whose category is ‘G’ (i.e. General) from a binary file “Customer.dat”. Assuming the binary file “Customer.dat” is containing objects of class CUSTOMER, which is defined as follows:
class CUSTOMER { int CId; // Customer Id char CName[30]; // Customer Name char Category: // Customer Type: G General // N Not General public: void Buy(); // Function to buy goods void Display(); // Function to display detail char GetCategory() { return Category; } };
SECTION B
Question 5.
(a) Illustrate Union operation between two tables/relations using a suitable example.
(b) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables.
(j) To display the details of those consumers whose Address is Delhi.
(ii) To display the details of STATIONARY whose price is in the range of 8 to 15 (both values included).
(iii) To display the ConsumerName, Address from table CONSUMER and display the Company and price from Table STATIONARY, with their
corresponding matching S_ID.
(iv) To display the number of consumers of each stationary.
(v) SELECT DISTINCT Address FROM CONSUMER; (vi) SELECT Company, MAX(Price), MIN(Price), COUNT(*) FROM STATIONARY GROUP BY Company: (vii) SELECT CONSUMER.ConsumerName, STATIONARY.StationaryName, STATIONARY.Price FROM STATIONARY, CONSUMER WHERE CONSUMER.S_ID=STATIONARY.S_ID; (viii) SELECT StationaryName, Price *3, C_ID AS ConsumerlD, Address FROM STATIONARY S, CONSUMER C WHERE S.S_ID=C.S_ID AND Conipany='ABC';
Question 6.
(a) State and verify commutative law algebraically.
(b) Draw a logic circuit for the following Boolean expression:
\(F=\bar { A } C+A\left( B+\bar { B } C \right)\)
Write the Product of Sum form of the function F(A, B, C) for the following truth table representation of F
Obtain a simplified form for following Boolean expression:
F(A, B, C, D) = Σ (1, 2, 3, 4, 6, 8, 11, 13, 14, 15) using Karnaugh map.
Question 7.
(a) State two reasons for which you may like to have a network of computers instead of having stand-alone computers.
(b) Differentiate between message switching and packet switching.
(c) In TCP/IP, what is the role played by TCP and IP individually?
(d) Which of the following crime(s) does not come under cybercrime?
(i) Stealing keyboard and mouse from a shop.
(ii) Copying some important data from a computer without taking permission from the owner of the data.
(e) “Connection India” is planning to start its offices in four major cities in India to provide regional IT infrastructure support in the field of Education and Culture.
The company has planned to set up its head office in New Delhi in three locations and have named their New Delhi offices as “SO”, “HO” and “TO”. The company’s regional offices are located at “Mumbai”, “Chennai” and “Jammu”. A rough layout of the same is given above.
Approximate distance between these offices
(i) Suggest network type (out of LAN, MAN, WAN) for connecting each of the following set of their offices:
I. Head Office and Tech Office
II. Head Office and Mumbai Office
(ii) Which device will you suggest to be procured by the company for connecting all the computers within each of their offices out of the following devices?
I. Modem
II. Telephone
III. Switch/Hub
(iii) Which of the following communication media, will you suggest to be procured by the company for connecting their local offices in New Delhi for very effective and fast communication?
I. Ethernet cable
II. Optical fiber
III. Telephone cable
(iv) Suggest a cable/wiring layout for connecting the company’s local offices located in New Delhi. Also, suggest an effective method/technology for connecting the company’s regional offices at “Mumbai”, “Chennai” and “Jammu”.
(f) A company wants to form a network on their five computers to a server within the company premises. Represent ring topology for the above network.
(g) Write the name of two application software which are free software.
Answers
Answer 1.
(a) Correct user defined data type are
(iii) class A {…}; A ob1;
(v) union stu
(vi) union stu s;
(vii) enum {red, green, blue};
(viii) struct stu {…};
(b) → cout, cin → abs( ) (c) #include void main() { int AT 1=1, 2, 3, 4, 5), Y.count: cin>>Y: count = Y: for(int i=count-1; i>= 0; i--) switch(i) { case 0: case 2:cout<<Y*A[i]< break; case 1: case 3: cout<<Y+A[i]; } }
(d) India is my motherland own country
(e) 50 3500 3570
50 50 3570
(f) The maximum value of Guess me is 24
The minimum value of Guess me is 10
The correct output will be (i) 24 and (iii) is 15.
Answer 2.
(a) Differences between the formal parameter and the actual parameter are as follows:
Formal Parameter | Actual Parameter |
It is a parameter, which is used in the function header, to receive the value from the actual parameter. | It is a parameter, which is used in the function call to send environment. |
The formal parameter is the parameter as defined on the function signature. | Actual parameter is when you actually pass real values in calling that function. |
e.g. # include void sum(int i, int j, int k); /* calling function */ int main() { int a = 5; sum(3; 2*a, a); //Actual parameter return 0; } /* called function */ /* formal parameter */ void sum(int i, int j, int k) { int s; s = i+j+k; cout<< "sum is" <<s; }
Here, 3, 2*a, a are actual parameter and i, j, k are formal parameter.
(b) (i) Constructor overloading
(ii) Function3 is destructor.
It is invoked when the memory allocated to the object of the class is deallocated.
(c) class HOTEL { int RoomNo; char Name[25]; float Charges; int Days; float Calculate() { float temp = Days * Charges; if (temp>10000) return(1.05* temp); return temp; } public: void InsertInfo() { cout<<"Enter the room no;"; cin>>RoomNo; cout<<"Enter the customer name"; cin>>Name; cout<<"Enter the room charges per day:"; cin>>Charges; cout<<"Enter number of days:"; cin>>Days; } void ShowInfo() { float Amount = Calculate(); cout<<"Room number:" <<RoomNo; cout<<"Customer Name:" <<Name; cout<<"Charges per day:" <<Charges; cout<<"Days:" << Days; cout<<"Total charges of customer:" <<Amount; } };
(d) (i) Multilevel Inheritance
(ii) 129 bytes
(iii) Enter(), Display(), Add(), Show(), lnput(), Output().
(iv) City[25]
Answer 3.
(a) void Find() { int a[4][4], b[16], i , j , k = 0, m = 4, n = 4; for(i=0; i<m; i++) for(j=0; j<n; j++) cin>>a[i][j]; for(i=0; i <m; i++) for(j=0; j<n; j++) { b[k]=a[i][j]; k++; } for(j=0; j<m*n; j++) cout<<b[j]; }
(b) M = 30 Ir = 0
N = 20 Ic = 0
W = 4 bytes
Add (A [20][13]) = ?
Add (A [9][13]) = 2000
Array is stored row wise
Add(A[I|[J]) = BA + [(I – Ir) * N + (J – Ic)] * W
Add(A [9][13]) = BA + [(9 – 0) * 20 + (13 – 0)] * 4
2000 = BA + [180 + 13] * 4
2000 = BA + 193 * 4
2000 = BA + 772
BA = 2000 – 772 = 1228
Add(A [20][13]) = 1228 + [(20 – 0) * 20 + (13 – 0)] * 4
= 1228 + [400 + 13] * 4
= 1228 + 413*4
= 1228 + 1652
= 2880
(c) void SelSort(int AR[], int n) { int POS.tmp; for(int i=0; i<n; i++) POS=i; for(int j=i+1; j<n; j++) { if(AR[j]<AR[P0S]) { POS=j; } } tmp = AR[POS]; AR[POS] = AR[i]; AR[i] = tmp; } cout<<"Sorted Array is:"; for(i=0; i< n; i++) cout<<AR[i]< }
(d) The expression is True OR False AND NOT False OR False
Result = True False OR False NOT AND False OR
(e) struct Country { char name[]; Country *next; }; Country * top=NULL; void PUSH() { Country *X; X = new Country; cout<<"Enter Country"; gets(X->name); X->next = top; top = X; } void POP() { Country *Z; if (top==NULL) { cout<<"Stack empty"; return; } Z=top; top=top-> next; delete Z; } void display() { Country *a = top; cout<<"The names of countries are"<<endi; while(a!=NULL) { cout<<"country"<name<<endl; a=a->next; } }
Answer 4.
(a) (i) FILE.seekp(Position); (ii) FILE.write((char *) &S, sizeof(S)); (b) int countupper() { ifstream fin(UPPERCASE.TXT"); int count=0; char ch; while(!fin.eof()) { fin.get(ch); if(isupper(ch)) count++; } fin.close(); return count; } (c) void displaydetail() { fstream file; file.open("Customer.dat", ios::out | ios::binary); CUSTOMER C; while(file.read((char*)&C ,sizeof(C))) if(C.GetCategory() ='G') C.Display(); file.close(); }
Answer 5.
(a) The UNION is used to combine and return all the distinct rows selected by query. Tables are said to be union compatible if,
(i) Both the tables are of the same degree.
(ii) The domains of corresponding attributes in both the tables should be same.
(b) (i) SELECT * FROM CONSUMER WHERE Address ='Del hi'; (ii) SELECT * FROM STATIONARY WHERE Price BETWEEN 8 AND 15; (iii) SELECT ConsumerName, Address, Company, Price FROM CONSUMER, STATIONARY WHERE CONSUMER.S_ID = STATIONARY.S_ID; (iv) SELECT COUNT(*), S_ID FROM CONSUMER GROUP BY S_ID;
Answer 6.
Answer 7.
(a) Two reasons to have a network of computers are as follows:
(i) To share computer resources like the printer, modem, database etc.
(ii) To transfer data safely and quickly.
(b) The differences between message switching and packet switching are as follows:
Message switching | Packet switching |
There is no limit to the size of packet, which can be transmitted. | A fixed size of the packet which can be transmitted across the network is specified. |
Data packets are stored on the disk. | All the packets of fixed size are stored in memory. |
(c) IP part of TCP/IP uses numeric IP addresses to join network segments. TCP part of TCP/IP provides reliable delivery of messages between networked computers.
(d) (i) Stealing keyboard and mouse from a shop.
(e) (i) I. Head Office and Tech Office – LAN
II. Head Office and Mumbai Office – WAN
(ii) III. Switch/Hub
(iii) II. An optical fiber
(iv) For local offices as shown in figure:
Technology for connecting regional offices is a satellite.
(f) Five computers connected using ring topology
(g) Free application software is as follows:
(i) GIMP GNU Image Manipulation Program
(ii) GNOME GNU Network Object Model Environment.
We hope the CBSE Sample Papers for Class 12 Computer Science Paper 2 help you. If you have any query regarding CBSE Sample Papers for Class 12 Computer Science Paper 2, drop a comment below and we will get back to you at the earliest.