CBSE Sample Papers for Class 12 Computer Science Paper 5 is part of CBSE Sample Papers for Class 12 Computer Science. Here we have given CBSE Sample Papers for Class 12 Computer Science Paper 5.
CBSE Sample Papers for Class 12 Computer Science Paper 5
Board | CBSE |
Class | XII |
Subject | Computer Science |
Sample Paper Set | Paper 5 |
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 5 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) What is the difference between implicit conversion and explicit conversion? Explain with suitable example.
(b) Write the name of the header file(s) that shall be needed for successful compilation of the following C++ code:
void main() { char string[30]; cin>>string; strcat(string, "KOSHIN"); cout<<string; }
(c) Rewrite the following program after removing the syntactical error(s), if any. Underline each correction.
#include<iostream.h> Structure Swim { int mem number; char name[30]; char type[] = "LIG": }; void main() { Swim per1, per2; cin<< "Member Number"; cin>>mem number.per1; cout<< "Member Name"; cin>>per1.name; perl.type="H"; per2=per1; cout<<"Hember Number:"<<per2.memnumber; cin<<"Member Name:"<<per2.memname; cout<<"Member Type:"<<per2.type; }
(d) What will be the output of the following program?
Note: Assume all required header files are already being included in the program.
void main() { clrscr(); int A[3][4]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; int n, m; for(n=0; n<3; ++n) for(m=0; m<4; ++m) if(A[n][m]*2==1) A[n][m]-- ; for(n=0; n<3; ++n) { cout<<endl; for(m=0; m<4; ++m) cout<<A[n][m]<<"\t"; } }
(e) Find and write the output of the following program:
Note: Assume all required header files are already being included in the program.
class friendname { char *name; int a; public: friendname() { a=0; name=new char[a + 1]; } friendname(char *f) { a=strlen(f); name=new char[a + 1]; strcpy(name, f); } void display() { cout<<name<<endl; } void modify(friendname &d,friendname &b) { a=d, a+b, a; delete name; name=new char[a + 1]; strcpy(name, d.name); strcat(name, b.name); } }; void main() { char *temp="Dark"; friendname name1(temp), name2("Soft"), name3("Doll"), name4 ("Barbie"), F1, F2, F3; F1.modify(name1, name2); F2.modify(F1, name3); F3.modify(name4, F2); F1.display(); F2.display(); F3.display(); }
(f) Look at the following C++ code and find the possible output (s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable G.
Note: Assume all the required header files are already being included in the program. The function random(n) generates an integer between 0 and n -1
void main() { randomize(); int G, H = 5; G=random(H)+30; for(int i=35; i>G; i--) cout<<i<<'$'; cout<<i; }
(i) 35$34$32$32$31$30$
(ii) 35$34$33$32$31
(iii) 30$31$32$33$34$35$36
(iv) 35$34$33$32$31$30
Question 2.
(a) Illustrate the use of inline function in C ++with the help of an example.
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note Assume all required header files are already being included in the program:
class Test { int Rno, marks; char subj[10]; public: Test() //Function1 { Rno=25; marks=95; strcpy(subj, "Math"); } Test(int Srno, int Smarks) //Function2 { Rno=Srno; marks=Smarks; } ~Test() //Function3 { cout<< "Test over"<<endl; } void show() //Function4 { cout<<Rno<<":"<<marks<<":"<<subj<<endl; } }; void main() { clrscr(); Test T1, T2(12, 96); for(int i=0; i<4; i++) { T1.show(); T2.show(); } getch(); }
(i) As per Object Oriented Programming, which concept is illustrated by Function1 and Function2 together?
(ii) How many times the message “Test over” will be displayed after executing the above C++ code?
(c) Define a class Sport in C++ with the following specifications:
Private members
- SportCode integer
- SportTitle 25 character
- Duration float
- Noofscenes integer
Public member functions
- A constructor function to initialise Duration as 50 and Noofscenes as 10.
- NewSport() function to accept values for SportCode and SportTitle.
- More info() function to assign the values of Duration and Noofscenes with the help of corresponding values passed as parameters to this function.
- Show() function to display all the data members on the screen.
(d) Consider the following code and answer the questions that are given below:
class B { int A1; void BFunc1(); protected: int B1; void BFunc2(); public: int C; void BFunc3(); } Ob1; class M:private B { int A2; protected: int B2; void MF1(); public: int C2; void MF2(); }Ob2; class D:protected M { void DF1(): int A3; pubiic: int B3; void DF2(): }Ob3;
(i) Which type of inheritance is shown in the above example?
(ii) Write name of the data members that are accessible in function DF1().
(iii) What would be the size of class D object?
(iv) Name the data members that are accessible in function F1().
Question 3.
(a) Write a function in C++ to modify the content of the array in such a way that the elements, which are multiples of 10, swap with the value present in the very next position in the array.
If array contains
56, 20, 66, 49, 40, 37, 30, 26
The output will be:
56, 66, 20, 49, 37, 40, 26, 30
(b) An array A[50][100] is stored in the memory along the row with each element occupying 2 bytes. Find out the address of the location A[20] [50], if location A[10] [25] is stored at the address 10000.
(c) Write a function in C++ to print the sum of both which are divisible by 2 and divisible by 3 elements from a two-dimensional array passed as the argument to the function.
If array contains
The output will be:
Sum of divisible by 2: 34
Sum of divisible by 3: 57
(d) Evaluate the following postfix notation of expression
20, 40,+,30, 20, -, *, 2, /
(e) Give necessary declarations for a queue containing float type numbers. Also, write a user-defined function in C++ to insert a float type number in the queue. You should use the linked representation of queue.
struct node { float data; node * link; }; class Queue() { node *front, *rear; public: Queue() { front=rear=NULL; } void Insert(); void Remove(); ~Queue(); };
Question 4.
(a) Consider a file F containing object M of class Master.
(i) Write statement to find the current position of the file pointer.
(ii) Write statement to move the file pointer to write the modified record back onto the file for the desired Mno.
(b) Write a function in C++, count the number of special character or spaces or numbers present in a text file ALPHABET.TXT except for alphabets.
If the content of the file ALPHABET.TXT is
& Arihant Publication 1@3 Computer_Science*
Then the output of the program should be 10.
(c) Assuming the class SHOP write functions in C++ to perform following:
(i) Write the objects of SHOP into a binary file.
(ii) Read the objects of SHOP from a binary file and display them on the screen.
class SHOP { int ITEMNO; char ITEM[10]; public: void GETIT() { cin>>ITEMNO; gets(ITEM); } void SHOWIT() { cout<<ITEMNO<<" "<<ITEM; } };
SECTION B
Question 5.
(a) Observe the following tables DISPLAY and MODEL.
(i) Identify the foreign key in the table ‘MODEL’.
(ii) Write the appropriate primary key for both the tables.
(b) Wife 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 details of those users whose City is Delhi.
(ii) To display the details of Item whose Price is in the range of 15000 to 30000 (both value included).
(iii) To display CName, City from table USER and ItemName an . Price from table ITEM with their corresponding matching ID.
(iv) To increase the Price of all Items by 2000 in the table ITEM.
(v) SELECT DISTINCT City FROM USER; (vi) SELECT ItemName, MAX(Price), COUNT(*) FROM ITEM GROUP BY ItemName; (vii) SELECT CName, Manufacturer FROM ITEM, USER WHERE ITEM. ID = USER.ID; (viii) SELECT ItemName, Price * 100, CName, City FROM ITEM, USER WHERE ITEM.ID=USER.ID AND ItemName LIKE 'Fridge';
Question 6.
(a) Prove \(\bar { X } YZ+\bar { X } Y\bar { Z } +XYZ+\bar { X } YZ=\bar { X } Y+YZ\) algebraically.
(b) Design a circuit to realise the following \(F=AB+A\bar { C } +\bar { AB } C\)
(c) Write the Sum of Product (SOP) form of the function G(U, V, W) for the following truth table representation of G.
(d) Obtain a simplified form for a Boolean expression
F(p, q, r, s) = Σ (0, 1, 3, 4, 5, 6, 7, 9, 10, 11, 13, 15) using Karnaugh map.
Question 7.
(a) Define the purpose of proxy server.
(b) What are the set of protocols used by Internet?
(c) Which switching technique uses ‘store and forward’ technique? Explain.
(d) Difference between PAN and LAN.
(e) Competition Learning is located in Shimla and is planning to go in for networking of four blocks for better interaction. The details are shown below:
(i) Suggest the type of networking (LAN, MAN, WAN) for connecting Library Block to Admin Block. Justify your answer.
(ii) Suggest the most suitable place (i.e. Block) to house the server with a suitable reason.
(iii) Suggest and placement of the following devices with reason:
I. Repeater
II. Switch
(iv) The institute is planning to link its study center situated in Delhi. Suggest an economic way to connect it with reasonably high speed. Justify your answer.
(f) Categorize the following extension under the static Web page and dynamic Web page:
(i) .htm
(ii) .asp
(iii) .html
(iv) .jsp
(g) Write the one advantage of each open source software and proprietary software.
Answers
Answer 1.
(a) Differences between implicit conversion and explicit conversion are as follows:
(b) → cin.cout → strcat( ) (c) #include<iostream.h> #include<string.h> struct Swim { int memnumber: char name[30]; char type[4]; }; void main() { Swim per1, per2; cout<<"Member Number"; cin>>per1.memnumber; cout<<"Member Name"; cin>>per1.name; strcpy(per1.type, "H"); per2=per1; cout<<"Member Number:"<<per2.memnumber: cout<<"Member Name:"<<per2.name: cout<<"Member Tvpe:"<<per2.type; }
(d) Output
0 2 2 4
4 6 6 8
8 10 10 12
(e) DarkSoft
DarkSoftDoll
BarbieDarkSoftDoll
(f) The possible outputs will be (ii) and (iv).
The maximum value of G = 34
The minimum value of G = 30
Answer 2.
(a) With inline function, the compiler replaces the function call statement with the function code itself and then compiles the entire code. Thus, with inline function, the compiler does not have to jump to another location to execute a function and then jump back.
Consider the following example:
inline void square(int i) { cout<<i*i: } void main() { square(6); . . . square(3); }
When the above program will be compiled, the compiler substitutes the function’s body in place of function call.
Compiled program will be as follows:
void main() { { cout<<i*i: } . . . { cout<<i*i; } }
(b) (i) Constructor overloading or polymorphism
(ii) 2 times the message “Test over” will be displayed after executing the C++ code.
(c) class Sport { int SportCode; char SportTitle[25]; float Duration; int Noofscenes; public: Sport() { Duration=50; Noofscenes=10; } void NewSport() { cout<<"\n Enter the code for Sport"; cin>>SportCode; cout<<"\n Enter the title of Sport"; gets(SportTitle); } void Moreinfo(float dur, int nos) { Duration=dur; Noofscenes=nos; } void Show() { cout<<"\n Sport Code:"<<SportCode; cout<<"\n Sport Title:"<<SportTitle; cout<<"\n Duration:"<<Duration; cout<<"\n Number of scenes:"<<Noofscenes; } };
(d) (i) Multilevel Inheritance
(ii) B2, C2, A3, B3
(iii) Size of class D object: 16
(iv) Data members that are accessible in function F1( ) are none because the function F1() is not the member function of any class.
Answer 3.
(a) void swap(int p[], int n) { int temp; for(int i=0; i<n; i++) { if(p[i]%10==0 && i<n-1) { temp=p[i]; p[i]=p[i+1]; p[i+1]=temp; i++; } } }
(b) Given,
Number of rows R = 50
Number of columns C = 100
Element size W = 2 bytes
Base address B =?
Lowest row Ir = 0
Lowest column Ic = 0
A [10][25] has address = 10000
A[l][J] = B+W*[C*(I – Ir) + (J – Ic)}
10000 = B + 2*[ 100 *( 10 – 0)+ (25 – 0)] = B + 2 *(1025) = B + 2050
B = 10000 – 2050 = 7950
A[I][J] = B + W*[C*(I – Ir) + (J – Ic)}
A[20][50] = 7950 + 2*[100 *(20 – 0) + (50 – 0)] = 7950 + 2 *(2050) = 7950 + 4100 = 12050
(c) void Sum(int A[][10], int row, int col) { int i, j, Sum1=0, Sum2=0; for(i=0; i<row; i++) for(j=0; j<col; j++) { if (A[i ][j]%2==0) Suml=Sum1+A[i][j]; if(A[i][j]%3==0) Sum2=Sum2+A[i][j]; } cout<<"Sum of divisible by 2: "<<Sum1<<endl; cout<<"Sum of divisible by 3: "<<Sum2<<endl; }
(d) The postfix notation of expression
20, 40, +, 30, 20, -, *, 2, /
Result = 300
(e) void Insert(float val) { node *temp; temp = new node; temp->data = val; temp->link = NULL; if(front==NULL) front=rear=temp; else rear->link=temp; rear=temp; } }
Answer 4.
(a) (i) F.tellg();
(ii) F.seekp(Pos-sizeof (c), ios::beg);
(b) void Count() { ifstream fin("ALPHABET.TXT"); int C=0; char CH=fin.get(): while(!fin.eof()) { if(!isalpha(CH)) C++; CH = fin.get(); } cout<<"Total count:"<<C; }
(c) (i) void write_ob(SHOP S) { ofstream ofs; ofs.open("SHOP.DAT", ios::out | ios::binary); if(!ofs) { cout<<"Cannot open file"; exit(0); } ofs.write((char*)&S, sizeof(S)); ofs.close(); } (ii) void read_ob() { ifstream fin; fin.open("SHOP.DAT", ios::in | ios::binary); if(ifin) { cout<<"Cannot open file"; exit(0); } SHOP S; while(fin.read((char *)&S, sizeof(S))) { S.SHOWIT(); } fin.close(); }
Answer 5.
(a) (i) DispID is the foreign key in MODEL table.
(ii) ModeINo is primary key for MODEL table and DispID is primary key for DISPLAY table.
(b) (i) SELECT * FROM USER WHERE City = 'Delhi'; (ii) SELECT * FROM ITEM WHERE Price BETWEEN 15000 AND 30000; (iii) SELECT CName, City, ItemName, Price FROM USER, ITEM WHERE USER.ID = ITEM.ID; (iv) UPDATE ITEM SET Price = Price + 2000;
Answer 6.
Answer 7.
(a) Proxy server intercepts all messages entering and leaving the network. The proxy server effectively hides the true network addresses.
(b) The communication protocol used by Internet are as follows:
(i) TCP (Transmission Control Protocol)
(ii) IP (Internet Protocol)
(c) In message switching technique, the source computer sends data or the message to the switching office first, which stores the data in its buffer. It then looks for a free link to another switching office and then sends the data to this office. Hence, store and forward.
(d) Differences between PAN and LAN are as follows:
PAN (Personal Area Network) |
LAN (Local Area Network) |
It is the interconnection of information technology devices with the range of an individual person. | Small computer networks that are confined to a localized area (e.g. an office, a building or a factory). |
The distance between various devices lies typically within a range of 10 m. | The distance between the nodes ranges between 1 to 10 km. |
(e) (i) Since, the distance between Library Block and Admin Block is small, so type of networking is small, i.e. LAN.
(ii) Since, maximum number of computers are in Student Block, so suitable place to house the server is Student Block.
(iii) I. Repeater should be installed between Student Block and Admin Block as distance is more than 60m.
II. Switch should be installed in each Block to connect several computers.
(iv) Broadband connection as it is between economical and speedy.
(f) Static Web Page
(i) .htm
(ii) .html
Dynamic Web Page
(i) .asp
(ii) .jsp
(g) Advantage of open source software: Low cost and no license fees.
Advantage of proprietary software: Reliable, professional support and training available.
We hope the CBSE Sample Papers for Class 12 Computer Science Paper 5 help you. If you have any query regarding CBSE Sample Papers for Class 12 Computer Science Paper 5, drop a comment below and we will get back to you at the earliest.