CBSE Sample Papers for Class 12 Computer Science Paper 1 is part of CBSE Sample Papers for Class 12 Computer Science. Here we have given CBSE Sample Papers for Class 12 Computer Science Paper 1.
CBSE Sample Papers for Class 12 Computer Science Paper 1
Board | CBSE |
Class | XII |
Subject | Computer Science |
Sample Paper Set | Paper 1 |
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 1 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) Out of the following, find those identifiers, which cannot be used for naming variable, constant or function in a C++ program:
lastName, _AVG, long, sum 1, name_1, pow, num^4, break
(b) Which C++ header file(s) are essentially required to be included to run/execute the following C++ source code?
void main() { char NAME[] = "COMPUTER": cout<<"Name Characters: "<<20-strlen(NAME)<<endl; }
(c) Rewrite the following C++ code after removing all the syntax error(s), if present in the code. Make sure that you underline each correction done by you in the code.
Note: Assume that all the required header files are already included, which are essential to run this code.
The corrections made by you do not change the logic of the program.
void main() { int a, sum=0; cin<<n; for(a=1; a>100; a+=2) if x%2=0 sum += a; cout>>"SUM=">>sum; }
(d) Find and write the output of the following program:
#include<iostream.h> static int i=100; void abc() { static int i=10; cout<<"a = "<<i: } main() { static int i=5; abc(); ' cout<<"b = "<<i<<endl; }
(e) What will be the output of the following code?
#include<iostream.h> class student { private: int m1, m2, m3; float per; public: student() { m1 = m2 = m3 = 0: per = 0.0; } void calc(int a, int b, int c) { m1 = a; m2 = b; m3 = c; per = (m1+m2+m3)/3.0; display(); } void display() { cout<<endl<<"Percentage = "<<per<<"%"; } }; void main() { student S1; S1.display(); S1.calc(75, 75, 75); S1.display(); }
(f) In the following program, find the correct possible output(s) from the options (i) to (iv). Also, write the maximum and minimum values that can be assigned to variable p.
Note: The function random(n) generates an integer between 0 and n.
#include<iostream.h> #include<stdlib.h> void main() { randomize(); char colorname[][10] = {"White","Pink","Red"."Orange"}; int p; for(int a=1; a<=3; a++) { p = random(2)+1; cout<<colorname[p]<<":"; } }
Output
(i) Pink: Red: Pink:
(ii) White: Pink: Red:
(iii) Pink: Red: Orange:
(iv) Pink: Red: Red:
Question 2.
(a) Why a destructor function required in a class? Illustrate with the help of an example.
(b) Answer the questions (i) and (ii) after going through the following class:
class Market { int Mcode; char Mname[25]; char Area[30]; public: Market() //Function1 { cout<<"Buy"<<endl; Mcode = 101; strcpy(Mname, "Brand"); strcpy(Area, "Meerut"); } Market(int M, char N[], char A[]) //Function2 { Mcode = M; strcpy(Mname, N); strcpy(Area, A); } void Ad(int M) //Function3 { Mcode += M; } void Display() //Function4 { cout<<Mcode<<":"<<Mname<<”:"<<Area<<endl; //Function4 } ~Market() //Function5 { cout<<"Market Closed !!!"<<endl; } }; void main() //Line1 { //Line2 Market M1, M2(105, "Brand New", "Abulane"); //Line3 for(int k=0; k<55; k++) //Line4 { //Line5 M1.Ad(25); M2.Ad(30); //Line6 M1.Display(); //Line7 M2.Display(); //Line8 } //Line9 } //Line10
(i) Which specific concept of Object Oriented Programming out of the following is illustrated by Function1 and Function2 combined together?
(ii) How many times the message “Market Closed!!!” will be displayed after executing the above C++ code? Out of Line1 to Line10 which Line is responsible to display the message “Market Closed!!!”?
(c) Declare a class Account to represent bank account of customers with the following data members:
Name of the depositor, Account number, Type of account(S for Savings and C for Current), Balance amount.
The class also contains member functions to be the following:
(i) To initialize data members
(ii) To deposit money
(iii) To withdraw money after checking the balance (minimum balance is Rs.1000)
(iv) To display the data members
(d) Consider the following C++ code and answer the questions (i) to (iv) given below:
class Office { int E; protected: int S, O; public: void INPUT(int); void OUTPUT(); }; class Dept: protected Office { int A, B; protected: void IN(int, int); public: void OUT(); }; class Employee: public Dept { int x; void DISPLAY(void); public: void ENTER(); };
(i) Name of tie base class and derived class of the class Dept.
(ii) Name of the data member(s) that can be accessed from function OUT().
(iii) Name of the private member function(s) of class Employee.
(iv) Which type of inheritance is illustrated in the above code?
Question 3.
(a) Write a function in C++ which accepts an integer array and its size as arguments and replace elements having even values with its half and elements having odd values with twice its value.
e.g. If an array of 4 elements initially contains the element as 1, 2, 4, 3
Then, the function should rearrange the content of the array as 2, 1, 2, 6
(b) An array A [20] [50] is stored in the memory along with the column with each of the element occupying 4 bytes. Find out the memory location for the element A[15] [10], if A[0] [0] is stored at the location 5200.
(c) Write a user-defined function Half(), which takes a 2D array Arr, with size M rows and N columns as arguments and prints the upper half of the array.
e.g. If array Arr is
2 3 4 5
7 8 9 0
7 6 3 2
1 3 6 7
The output will be
\(2\quad 3\quad 4\quad 5\\ \quad \quad 8\quad 9\quad 0\\ \quad \quad \quad \quad 3\quad 2\\ \quad \quad \quad \quad \quad \quad 7\)
(d) Convert the following infix expression to its equivalent postfix expression.
Showing stack contents for the conversion.
(X + Y * (Z – P)/Q)
(e) Write a function in C++ to delete a node containing student’s information from a dynamically allocated stack of students implemented with the help of the following structure:
struct Student { int RNO; char Name[30]; Student * Next; }; class STACK { Student *top; public: STACK() { top=NULL; } void Pop(); void Push(); ~STACK(); };
Question 4.
(a) Find the output of the following C++ code considering that the binary file “Applicant.dat” exists on the hard disk with a data of 200 Applicants.
class Applicant { int Aid; char Name[20]; public: void Enter(); void Result(); }; void main() { ifstream f; f.open("Applicant.dat", ios::binary | ios::out); Applicant A; int c=0; while(c<=3) { f. read!(char*)&A, sizeof(A)); C++; } int POS=f.tellg()/sizeof(A); cout<<"\nPresent Record:"<<P0S<<endl; f.close(); }
(b) Write a function in C++ to count the number of lowercase alphabets present in a text file.
e.g. If the content of the file “Report.txt” is as follows:
Full form of HTML is HyperText Markup Language.
The function count() should display:
30
(c) Given a binary file PHONE.DAT, containing records of the following structure type:
class Phonelist { char Name[20]; char Address[30]; char AreaCode[5]; char PhoneNo[15]; public: void Register(); void Transfer(); int CheckCode(char AC[]) { return strcmp(AreaCode.AC); } };
Write a function Transfer( ) in C++ that would copy all those records which are having AreaCode as “DEL” from PHONE.DAT to PHONE BACK. DAT.
SECTION B
Question 5.
(a) Consider the tables TEACHERS and STUDENTS given below:
Answer the following questions:
(i) Write the primary key of both the tables.
(ii) Write the Degree of both the tables.
(b) Observe the following CONSIGNOR and CONSIGNEE tables carefully and write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables.
(i) To display the names of all consignors from Mumbai.
(ii) To display the CneelD, CnorName, CnorAddress, CneeName, Cnee Address for every consignee.
(iii) To display consignee details in ascending order of CneeName.
(iv) To display number of consignors from each city.
(v) SELECT DISTINCT CneeCity FROM CONSIGNEE; (vi) SELECT A.CnorName, B.CneeName FROM CONSIGNOR A, CONSIGNEE B WHERE A.CnorID=B.CnorlD AND B.CneeCity = "Mumbai"; (vii) SELECT CneeName, CneeAddress FROM CONSIGNEE WHERE CneeCity NOT IN ("Mumbai","Kolkata"); (vui) SELECT CnorName, City, Price, CneeName FROM CONSIGNOR A, CONSIGNEE B WHERE A.CnorID=B.CnorID AND Price<6000;
Question 6.
(a) Simplify the given Boolean expression:
\(F=XY\left( \bar { X } Y\bar { Z } +X\bar { Y } \bar { Z } +X\bar { Y } \bar { Z } \right)\)
(b) Draw logic circuit for the following:
\(F=\bar { AB } D+\bar { AC } D+\bar { BC } D+A\bar { B } C\bar { D }\)
(c) Express in POS form, the Boolean function F(P, Q, R), the truth table for which is given below:
(d) Reduce the following Boolean expression using K-map
H(P, Q, R, S) = Π (0, 1, 4, 5, 6, 7, 11, 12, 13, 14, 15)
Question 7.
(a) Differentiate between GSM and CDMA mobile computing technologies.
(b) If someone has hacked your Website, to whom you lodge the complaint.
(c) Compare freeware and shareware.
(d) Which transmission medium permits data transmission rates of about 16 gigabits per second?
Also, write its one disadvantage.
(e) “India Technical Ltd” (ITL) is planning to expand its network in India, starting with two cities in India to provide infrastructure for the distribution of its products. The company has planned to set up its main office units in Mumbai at the different locations and have named their offices as Production Unit, Finance Unit, and Media Unit. The company has its Corporate Unit in Delhi.
A rough layout of the same as follows:
Approximate distance between these units
From | To | Distance |
Production Unit | Finance Unit | 70 m |
Production Unit | Media Unit | 15 km |
Production Unit | Corporate Unit | 12 km |
Finance Unit | Media Unit | 15 km |
In the above units, the company experts have planned to install the following number of computers in each of their office units
Production Unit | 150 |
Finance Unit | 35 |
Media Unit | 10 |
Corporate Unit | 30 |
(i) Suggest the kind of network required (out of LAN, MAN and WAN) for connecting each of the following office units:
I. Production Unit and Media Unit
II. Production Unit and Finance Unit
(ii) Which one of the following devices will you suggest for connecting all the computers within each of
their office units?
I. Switch/Hub
II. Modem
III. Telephone
(iii) Which of the following communication media, will you suggest to be processed by the company for
connecting their local office units in Mumbai for very effective (high speed) communication?
I. Telephone cable
II. Optical fiber
III. Ethernet cable
(iv) Suggest a cable/wiring layout for connecting the company’s local office units located in Mumbai. Also,
suggest an effective method/technology for connecting the company’s office unit located in Delhi.
(f) Out of the following which all does not come under IT Act?
(i) Misrepresentation
(ii) Steal a brand new computer from showroom
(iii) Failure to maintain a record
(iv) Publishing information which is obscene in electronic form.
(g) What are the types of viruses? Explain.
Answers
Answer 1.
(a) Identifiers which cannot be used for naming variable, constant or function are long, sum 1, pow, num^4,
break.
(b) → cout → strlen (c) void main() { int a, sum=0; cin>>a: for(a=1; a<100; a+=2) if(a%2==0) sum+= a; cout<<"SUM = "<<sum: }
(d) Output
a = 10
b = 5
(e) Output
Percentage = 0%
Percentage = 75%
Percentage = 75%
(f) The possible outputs are (i) and (iv)
The maximum value of p = 3
The minimum value of p = 1
Answer 2.
(a) During the construction of an object by the constructor, resources are allocated for use, e.g. allocation of memory, opening of file etc. These allocated resources must be deallocated before the object is destroyed. A destructor is responsible for this task and performs all clean-up jobs like closing a file, deallocating and releasing memory area automatically.
e.g. class A { int num; public: A() { cout<<"Object Created"< } ~A() { cout<<"Object Destroyed"<<endl; } }; void main() { A obj; }
(b) (i) Polymorphism
(ii) 2 times the message ‘Market Closed!!!” will be displayed.
Line3 is responsible to display the message “Market closed!!!”.
(c) class Account { char D_Name[30]; float Amount; char acc_type; long Acc_No; public: void initial() { cout<<endl<<"Enter Depositors Name:"; gets(D_Name); cout<<endl<<"Enter Account Number:"; cin>>Acc_No; cout<<endl<<"Enter Type of account(S for Saving and C for Current):"; cin>>acc_type; cout<<endl<<"Enter Amount:"; cin>>Amount; } void Deposit() { float dip; cout<<"Enter Money to deposit:"; cin>>dip; Amount=Amount+dip; cout<<"After deposit total amount is:"<<Amount; } void Withdraw() { float wid; cout<<endl<<"Enter money to withdraw:"; cin>>wid; if(Amount>=1000) { display(); Amount=Amount - wid; cout<<"After withdraw'the amount is:"<<Amount; } else { cout<<"... you can not withdraw money....."; } } void display() { cout<<"Depositors Name:"<<D_Name<<endl; cout<<"Account Number:"<<Acc_No<<endl; cout<<"Account Type:"<<acc_type<<endl; cout<<"Amount:"<<Amount<<endl; } };
(d) (i) Base class is Office and derived class is Employee.
(ii) S, O, A, B
(iii) DISPLAY()
(iv) Multilevel Inheritance
Answer 3.
(a) void Arrange(int A[], int n) { for(int i=0; i<n; ++i) { if(A[i]%2==0) A[i]*= 2; else A[i] *= 2; for(i=0; i<n; i++) cout<<A[i]<<"\t"; }
(b) Base address (S) = 5200
W = 4 bytes, I = 15, J = 10, M = 20 and N = 50
Add (A[I] [J]) = Base address + W*[I+J*M]
Add (A[15][10]) = 5200 + 4*[15+10*20] = 5200 + 4*[15+200] = 5200+4*[215] = 5200 + 860 = 6060
(c) void Half(int Arr[]C10], int M, int N) { int i, j; for(i=0; i<M; i++) { for(j=0; j<N; j++) { if (i<=j ) cout<<Arr[i][j]<<" "; else cout<<" "; } cout<<"\n"; } }
(d) Given, (X + Y * (Z – P)/Q)
Output XYZP-*Q/+
(e) void Pop(Student *top) { Student *ptr = top; if (ptr == NULL) cout<<"Underflow !!"; else { cout<<"Element being deleted is\n"; cout<<"Rno"<RNO; cout<<"Name”<Name; top=top->Next; delete ptr; } }
Answer 4.
(a) Present Record : 3
(b) void count() { char ch; int d=0; ifstream ifs; ifs.open("Report.txt", ios::out | ios::binary); if(!ifs) { cout<<"file does not exist"; exit(0); } whi1e(!ifs.eof()) { ifs.get(ch); if(islower(ch)) d++; } cout<<"Number of lowercase letters="<<d<<endl; }
(c) void Transfer() { Phonelist obj; fstream f("PHONE.DAT", ios::in | ios::binary); fstream f1("PHONEBACK.DAT", ios::out | ios::binary); while(!f.eof()) { f.readf(char*)&obj, sizeof(obj)); if((obj.CheckCode, "DEL") == 0) f1.write((char*)&obj, sizeof(obj)); } f.close(); f1.close(); }
Answer 5.
(a) (i) Primary key of table TEACHERS is TID.
Primary key of table STUDENTS is SID.
(ii) Degree of tables TEACHERS and STUDENTS are 3 and 3, respectively.
(b) (i) SELECT CnorName FROM CONSIGNOR WHERE City = 'Mumbai'; (ii) SELECT CneelD, CnorName, CnorAddress, CneeName, Cnee Address FROM CONSIGNOR,
CONSIGNEE
WHERE CONSIGNOR.CnorID=C0NSIGNEE.CnorID; (iii) SELECT * FROM CONSIGNEE ORDER BY CneeName; (iv) SELECT City, COUNT(City) FROM CONSIGNOR GROUP BY City;
Answer 6.
Answer 7.
(a) Differences between GSM and CDMA mobile computing technologies are as follows:
GSM | CDMA |
It has a maximum download speed of 384 Kbps. | It has a maximum download speed of 2 Mbps. |
GSM network emits continuous wave pulses. Radiation is 28 times more than CDMA. | No radiation is emitted. |
Dominant standards worldwide. | Dominant standard in the United States. |
(b) The complaint has to be lodged with the police under the IT Act.
(c) Freeware, the name derived from words “free” and “software”. It is a computer software that is available for use at no cost or for an optional fee. While, Shareware is usually offered as a trial version with certain features only available after the license is purchased, or as a full version, but for a trial period.
(d) Microwave
One disadvantage of microwave is as follows:
Microwave propagation is susceptible to weather effects like rains, thunder storms etc.
(e) (i) I. Production Unit and Media Unit – MAN
II. Production Unit and Finance Unit – LAN
(ii) I. Switch/Hub
(iii) II. Optical fibre
(iv) Cable Layout
Effective technology to connect with the office situated in Delhi is satellite transmission.
(f) (ii) Steal a brand new computer from showroom.
(g) There are broadly three types of viruses as follows:
(i) File infectors attach themselves to a program file.
(ii) Boot sector viruses install themselves on the beginning tracks of a hard drive.
(iii) Macro viruses infect data files.
We hope the CBSE Sample Papers for Class 12 Computer Science Paper 1 help you. If you have any query regarding CBSE Sample Papers for Class 12 Computer Science Paper 1, drop a comment below and we will
get back to you at the earliest.