CBSE Sample Papers for Class 12 Computer Science Paper 3 is part of CBSE Sample Papers for Class 12 Computer Science. Here we have given CBSE Sample Papers for Class 12 Computer Science Paper 3.
CBSE Sample Papers for Class 12 Computer Science Paper 3
Board | CBSE |
Class | XII |
Subject | Computer Science |
Sample Paper Set | Paper 3 |
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 3 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 with in each Section.
- Programming Language in SECTION A : C++.
- Answer the questions after carefully reading the text.
SECTION A
Question 1.
(a) Explain conditional operator with suitable example.
(b) Which C++ header file(s) are essentially required to be included to run/execute the following C++ code:
void main () { char *word1= "Hello", *word2="Friends"; strcat(word1, word2); cout<<word1: }
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction.
#include<conio.h> #include<iostream.h> #include<string.h> #include<stdio.h> class product { int product_code, qty, price; char name[20]; public: product() { product_code=0; qty=0; price=0; name=NULL; } void entry() { cout<<'\n Enter code, qty, price"'; cin>>product_code>>qty>>price; gets(name); } void tot_price() {return qty*price;} }; void main() { p product; p.entry(); cout<<tot_price(); }
(d) Write the output of the following C++ program code:
NOTE: Assume all required header files are already being included in the program.
void change(int *s) { for(int i=0; i<4; i++) { if(*s<40) { if(*s%2=0) *s=*s+10; else *s=*s+11; } else { if(*s%2==0) *s=*s-10; else *s=*s-11; } } cout<<*s<<" "; s++; } } void main() { int score[] = {25, 60, 35, 53); change(score); }
(e) Write the output of the following C++ program code:
NOTE: Assume all required header files are already being included in the program.
class seminar { char topic[30]; int charges; public: seminar() { strcpy(topic, "Registration"); charges=5000; } seminar(char t[]) { strcpy(topic, t); charges=5000; } seminar(int c) { strcpy(topic, "Registrati on with Discount"); charges=5000-c; } void regis(char t[],int c) { strcpy(topic,t); charges=charges+c; } void regis(int c=2000) { charges=charges+c; } void subject(char t[], int c) { strcpy(topic, t); charges=charges+c; } void show() { cout<<topic<<"@"<<charges<<endl; } }; void main() { seminar s1, s2(1000), s3("Genetic Mutation"), s4; s1.show(); s2.show(); s1.subject("ICT", 2000); s1.show(); s2.regis("Cyber Crime", 2500); s2.show() ; s3.regis(); s3.show(); s4=s2; s4.show(); getch(); }
(f) Observe the following program carefully and attempt the given questions:
#include<iostream.h> #include<conio.h> #include<stdlib.h> void main() { clrscr(); randomize() ; char courses[][10]={"M.Tech", "MCA", "MBA", "B.Tech"}; int ch; for(int i=1; i<=3; i++) { ch=random(i)+1; cout<<courses[ch]<<"\t"; } getch(); }
(i) Out of all the four courses stored in the variable courses, which course will never be displayed in the output and which course will always be displayed at first in the output?
(ii) Mention the minimum and the maximum value assigned to the variable ch.
Question 2.
(a) What do you understand by function overloading or functional polymorphism? Explain with suitable example.
(b) Answer the questions (i) and (ii) after going through the following class:
class planet { char name[20]; char distance[20]; public: planet() //Function 1 { strcpy(name, "Venus"); strcpy(distance, "38 million km"); } void display(char na[], char d[]) //Function 2 { cout<<na<<"has" <<d<< "distance from Earth" <<endl; } planet(char na[], char d[])//Function 3 { strcpy(name, na); strcpy(distance, d); } ~planet() //Function 4 { cout<<"Planetariurn time over!!!" <<endl; } };
(i) What is Function 1 referred as? When will it be executed?
(ii) Write suitable C++ statement to invoke Function 2.
(c) Define a class DanceAcademy in C++ with following description:
Private Members
- Enroll no of type int
- Name of type string
- Style of type string
- Fee of type float
- A member function chkfee() to assign the value of fee variable according to the style entered by the user according to the criteria as given below:
Public Members
- A function enrollment() to allow users to enter values for Enrollno, Name, Style and call function chkfee() to assign value of fee variable according to the Style entered by the user.
- A function display() to allow users to view the details of all the data members.
(d) Answer the questions (i) to (iv) based on the following:
class indoor_sports { int i_id; char i_name[20]; char i_coach[20]; protected: int i_rank, i_fee; void get_ifee(); public: indoor_sports(); void iEntry(); void ishow(); }; class outdoor_sports { int o_id; char o_name[20]; char o_coach[20]: protected: int orank, ofee; void get_ofee(); public: outdoor_sports(); void oEntry(); void oshow(): }; class sports: public indoor_sports, protected outdoor_sports char rules[20]; public: sports(); void registration(); void showdata(); };
(i) Name the type of inheritance illustrated in the above C++ code.
(ii) Write the names of all the members, which are accessible from the objects belonging to class outdoor_sports.
(iii) Write the names of all the member functions, which are accessible from the member function of class sports.
(iv) What will be the size of the object belonging to class indoor_sports?
Question 3.
(a) Write the definition of a function grace_score (int score[], int size) in C++, which should check all the elements of the array and give an increase of 5 to those scores which are less than 40.
Example: if an array of seven integers is as follows:
45, 35, 85, 80, 33, 27, 90
After executing the function, the array content should be changed as follows:
45, 40, 85, 80, 38, 32, 90
(b) An array P[30][20] is stored along the column in the memory with each element requiring 2 bytes of storage. If the base address of the array P is 26500, find out the location of P[20] [10].
(c) Write the definition of a member function push() for a class Library in C++ to insert a book information in a dynamically allocated stack of books considering the following code is already written as a part of the program:
struct book { int bookid; char bookname[20]; book *next; }; class Library { book *top; public: Library() { top=NULL; } void push(); void pop(); void disp(); ~Library(); };
(d) Write a user-defined function swap_row(int ARR[ ] [3] , int R, int C) in C++ to swap the first row values with the last row values:
e.g. if the content of the array is:
Then after function call, the content of the array should be.
(e) Evaluate the following Postfix expression. Show the status of Stack after execution of each operation separately:
45, 45, +, 32, 20, 10, /, – ,*
Question 4.
(a) Find the output of the following C++ code considering that the binary file sp.dat already exists on the hard disk with 2 records in it.
class sports { int id; char sname[20]; char coach[20]; public: void entry(); void show(); void writing(); void reading(); }s; void sports::reading() { ifstream i; i.open("sp.dat"); while { i.read((char*)&s, sizeof(s)); if(i.eof()) break; else cout<<"\n" <<i.tellg(); } i.close(); } void main() { s.reading(); }
(b) Write a user defined function word_count() in C++ to count how many words are present in a text file named “opinion.txt”. e.g. if the file opinion, txt contains following text:
Co-education system is necessary for a balanced society. With co-education system, Girls and Boys may develop a feeling of mutual respect towards each other.
The function should display the following:
Total number of words present in the text file are: 24
(c) Write a function display() in ++ to display all the students who have got a distinction (scored percentage more than or equal to 75) from a binary file “stud.dat”, assuming the binary file is containing the objects of the following class:
class student { int rno; char sname[20]; int percent; public: int retpercent() { return percent; } void getdetails() { cin>>rno; gets(sname); cin>>percent; } void showdetails() { cout<< rno; puts(sname); cout<<percent; } };
SECTION B
Question 5.
(a) Observe the table ‘Club’ given below:
(i) What is the cardinality and degree of the above-given table?
(ii) If a new column Contact no has been added and three more members have joined the club then how these changes will affect the degree and cardinality of the above-given table.
(b) Write SQL commands for the queries (i) to (iv) and output for (v) to (viii) based on the tables ‘Watches’ and ‘Sale’ given below:
(i) To display all the details of those watches whose name ends with ‘Time’.
(ii) To display watch’s name and price of those watches which have price range iii between 5000-15000.
(iii) To display total quantity in store of Unisex type watches.
(iv) To display watch name and their quantity sold in first quarter.
(v) SELECT MAX(Price), MIN(Qty_Store) FROM Watches; (vi) SELECT Quarter, SUM(Qty_Sold) FROM Sale GROUP BY Quarter; (vii) SELECT Watch_Name, Price, Type FROM Watches w, Sale s WHERE w.Watchid!=s.Watchid; (viii) SELECT Watch_Name, Qty_Store, SUM(Qty_Sold), Qty_Store SUM(Qty_Sold) "Stock" FROM Watches w, Sale s WHERE w.Watchid=s.Watchid GROUP BY s.Watchid;
Question 6.
(a) Correct the following boolean statements:
(i) X + 1 = X
(ii) (A’)’ = A
(iii) A + A’ = 0
(iv) (A + B)’ = A.B
(b) Draw the equivalent logic circuit for the following Boolean expression:
(A.B) + C
(c) Write the POS form of a Boolean Function F, which is represented in a truth table as follows:
(d) Reduce the following Boolean Expression using K-Map:
F(A, B, C, D) = Σ (0, 1, 3, 5, 6, 7, 9, 11, 13, 14, 15)
Question 7.
(a) Identify the type of topology on the basis of the following:
(i) Since every node is directly connected to the server, a large amount of cable is needed which increases the installation cost of the network.
(ii) It has a single common data path connecting all the nodes.
(b) Expand the following:
(i) VOIP
(ii) SMTP
(c) Who is a hacker?
(d) The following is a 32-bit binary number usually represented as 4 decimal values, each representing 8 bits, in the range 0 to 255 (known as octets) separated by decimal points.
140.179.220.200
What is it? What is its importance?
(e) Daniel has to share the data among various computers of his two offices branches situated in the same city. Name the network (out of LAN, WAN, PAN, and MAN) which is being formed in this process.
(f) Rehaana Medicos Center has set-up its new center in Dubai. It has four buildings as shown in the diagram given below:
Distances between various buildings are as follows:
As a network expert, provide the best possible answer to the following queries:
(i) Suggest a cable layout of connections between the buildings.
(ii) Suggest the most suitable place (i.e. buildings) to house the server of this organization.
(iii) Suggest the placement of the following device with justification:
I. Repeater
II. Hub/Switch
(iv) Suggest a system (hardware/software) to prevent unauthorized access to or from the network.
Answers
Answer 1.
(a) Conditional Operator: It is also known as a ternary operator because it requires three operands. The conditional operator (?:) is a condensed form of an if-then-else statement. The question mark (?) and the colon (:) are the special characters used to form the conditional expression.
Syntax:
Expression 1? Expression 2: Expression 3
Explanation:
Expression 1 is evaluated first. If it is true, then Expression 2 is evaluated or if it is false, then Expression 3 is evaluated.
Example:
int y = 10, x; x=y>10?1:0; cout<<x;
Output: 0
(b) Required header files are as follows.
#include<iostream.h> #include<string.h>
(c) #include<conio.h> #include<iostream.h> #include<string.h> #include<stdio.h> class product { int product_code, qty, price; char name[20]; public: product() { product_code=0; qty=0; price=0; strcpy(name, NULL); } void entry() { cout<<"\n Enter code, qty, price"; cin>>product_code>>qty>>price; gets(name); } int tot_price() {return qty*price;} }; void main() { product p; p.entry(); cout<<p.tot_price(); }
(d) Output of the given C++ program code:
36 50 46 42
(e) Output of the given C++ program code :
Registration@5000
Registration with Discount@4000
ICT@7000
Cyber Crime@6500
Genetic Mutation@7000
Cyber Crime@6500
(f) (i) M.Tech will never be displayed in the output.
MCA will always be displayed at first in the output.
(ii) Minimum value of ch = 1 and
Maximum value of ch = 3
Answer 2.
(a) Function Overloading or Functional Polymorphism: It is a method of using the same function or method to work using different sets of input. Function overloading is one of the example of polymorphism, where more than one function carring same name behave differently with different set of parameters passed to them.
Example
int area(int length, int breadth) { return(length*breadth); } float area(int base, float height) { return(base*height/2); }
(b) (i) Function 1 referred to as a constructor.
It will be executed at the time of object creation.
(ii) C++ statement to invoke Function 2:
pianet p;
p.display(“piuto”, “7.5 Billion km”);
(c) class DanceAcademy { int Enrollno; char Name[15]; char Style[15]; float Fee; void chkfee() { if (strcmpi (Style, "Classical" )==0) Fee=10000; else if(strcmpi(Style,"Western")==0 Fee = 8000; else if(strcmpi(Style, "Freestyle")=0) Fee=11000; } public: void enrollment() { cout<<"Please enter enroll no, name and style"; cin>>Enrollno>>Name>>Style; chkfee(); } void display() { cout<<"\n Entered Enrollno is" <<"\t"<<Enrollno; cout<<"\n Entered Name is"<<"\t"<<Name; cout<<"\n Entered Style is:"<<"\t"<<Style; cout<<"\n and Fee is : "<<"\t"<<Fee; } };
(d) (i) Multiple inheritance
(ii) Data members : None
Member Functions : oEntry(), oshow()
(iii) registration(), showdata(), oEntry(), oshow(), get_ofee(), iEntry(), ishow(), get_ifeeO.
(iv) 46 bytes
Answer 3.
(a) void grace_score(int score[], int size) { for (int i=0; i<size, i++) if(score[i]<40) score[i]=score[i]+5; cout<<score[i]<<" "; } }
(b) Total number of rows (R) = 30
Size of each element (W) = 2
Base Address (B) = 26500
Assuming lower bound of row(LBR) = 0
and lower bound of column (LBC) = 0
LOC(P[l][J]) = B+W[(I – LBR) + (J – LBC)*R]
LOC(P[20][10]) = 26500 + 2[(20 – 0) + (10 – 0) * 30]
= 26500 + 2[20 + 10 x 30]
= 26500 + 2[20 +300]
= 26500 + 2 x 320
= 26500 + 640
= 27140
Hence, Location of P[20][10] is 27140.
(c) void Library::push() { book *nptr; nptr=new book; cout<<"Enter values for bookid and bookname"; cin>>nptr->bookid>>nptr->bookname; nptr->next=NULL; if(top==NULL) top=nptr; else { nptr->next=top; top=nptr: } }
(d) void swap_row(int ARR[ ][3], int R, int C) { for(int i=0; i<R; i++) { for(int j=0: j<C; j++) { int temp=ARR[i][j]: ARR[i][j]=ARR[R-1][j]; ARR[R-1][j]=temp; } } }
(e) Given POSTFIX expression is : 45, 45, +, 32, 20, 10, /, -, *
Hence, the output is 2700.
Answer 4.
(a) 42
84
(b) void word_count() { ifstream i; char ch[20]; int c=0; while(! i.eof(1)) { i>>ch; c=c+1; } cout<<"Total number of words present in the text file are:"<<c; } (c) void display() { student s; ifstream i(stud.dat"); while(i .read((char*)&s, sizeof(s))) { if(s.retpercent()>=75) s.showdetails(): } i.close(); }
Answer 5.
(a) (i) Cardinality = 4 and Degree = 5
(ii) Cardinality = 7 and Degree = 6
(b) (i) SELECT * FROM Watches WHERE Watch_Name LIKE '%Time'; (ii) SELECT Watch_Name, Price FROM Watches WHERE Price BETWEEN 5000 AND 15000; (iii) SELECT SUM(Qty_Store) FROM Watches WHERE Type LIKE 'Unisex'; (iv) SELECT Watch_Name, Qty_Sold FROM Watches W, Sale S WHERE W.Watchid=S.Watchid AND Quarter = 1;
Answer 6.
(a) Correct boolean statements are as follows
(i) X + 1 = 1 or X + 0 = X
(ii) (A’)’ = A
(iii) A + A’ = 1 or A.A’ = 0
(iv) (A+ B)’ = A’.B’
(b) Given Boolean expression is (A.B) + C
Answer 7.
(a) (i) Star Topology
(ii) Bus Topology
(b) (i) VOIP – Voice Over Internet Protocol
(ii) SMTP – Simple Mail Transfer Protocol
(c) Hacker: A computer enthusiast, who uses his computer programming skills to intentionally access a computer without authorization is known as hacker. A hacker accesses the computer without the intention of destroying data or maliciously harming the computer.
(d) It is an IP address. It is used to identify the computers on a network.
(e) MAN
(f) (i) Layout
(ii) The most suitable place/building to house the server of this organisation would be building Research Lab, as this building contains the maximum number of computers.
(iii) I. Since the cabling distance between Accounts to Store is quite large, so a repeater would ideally be needed along their path to avoid loss of signals during the course of data flow in this route.
II. Hub/Switch each would be needed in all the buildings to interconnect the group of cables from the different computers in each building.
(iv) Firewall.
We hope the CBSE Sample Papers for Class 12 Computer Science Paper 3 help you. If you have any query regarding CBSE Sample Papers for Class 12 Computer Science Paper 3, drop a comment below and we will get back to you at the earliest.