CBSE Sample Papers for Class 12 Computer Science Paper 4 is part of CBSE Sample Papers for Class 12 Computer Science. Here we have given CBSE Sample Papers for Class 12 Computer Science Paper 4.
CBSE Sample Papers for Class 12 Computer Science Paper 4
Board | CBSE |
Class | XII |
Subject | Computer Science |
Sample Paper Set | Paper 4 |
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 4 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) Which of the following is/are invalid C++ statement (s)?
(i) 5 = ++ val+ val++;
(ii) a=val+++++val;
(iii) if (5 == sqrt (25))
(iv) -b+ sqrt = 6 *a;
Justify your answer.
(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?
#define PI 3.14159265 int main() { double param, result; param=60.0; result=cos(param * PI/180.0); cout<<"The cosine of "<<param<<" degrees is "<<result; cout<<endI; return 0; }
(c) Rewrite the following program after removing the syntactical error(s), if any. Underline each correction.
Note: Assume all required header files are already being included in the program.
const int n 10; Void main() { int A[n]; A={30,25,20,15,10} ; for(b=0; b<n; b++) } A[b]+=10; cout>>A[b]; }
(d) Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
void main() { int arr[] = {10, 23, 30, 40}; int *ptr = am; int val = *ptr; cout<<val<<endl; val = *ptr++; cout<<val<<endl; val = *ptr; . cout<<val<<endl; val = *++ptr; cout<<val<<endl; }
(e) What will be the output of the following C++ program segment?
Note: Assume all required header files are already being included in the program.
class Show { static int x; int y, z; public: Show(int i, int j ) { y = i; z = j; x++; } void display() { cout<<"y = "<<y<<endl; cout<<"z = "<<z<<endl; } static void disp() { cout<<''x = "<<x<<endl; } }; int Show::x = 10; void main() { Show S1(7, 2), S2(6, 3), S3(5, 2); s1.display(); Show::disp(); s2.display(); s3.display(); Show::disp(); }
(f) Observe the following C++ code and find out, which out of the given options (i) to (iv) are the expected correct output. Also, assign the maximum and minimum value that can be assigned to the variable ToGo.
Note: Assume all required header files are already being included in the program.
random (n) function wilt generate the numbers between 0 to n- 1
void main() { randomize(): char Area[][10]={"NORTH","SOUTH","EAST","WEST"}; int ToGo; for(int I = 0; I<3; I++) { ToGo=random(2)+1; cout<<Area[ToGo]<<":"; } }
(i) SOUTH:EAST:SOUTH
(ii) NORTH:SOUTHEAST
(iii) SOUTH: EAST: WEST
(iv) SOUTH: EAST: EAST
Question 2.
(a) Differentiate between Pass by value and Pass by reference giving suitable example.
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary header files are already being included in the program:
class Salary { int Empld, DeptCode; public: Salary(int Eld): //Function1 Salary(); //Function2 Salary(Salary &S); //Function3 void Input(); //Function4 void Output(); //Function5 }; void main() { Salary S(25); //Statement1 }
(i) Which of the function will get executed, when Statement1 is executed in the above code?
(ii) Write a statement to declare a new object L with reference to already existing object S using Function3.
(c) Define a class Travel in C + + with the description given below:
Private members
- T_Code of type string
- No_of_Adults of type string
- No_of_Children of type string
- The distance of type string
- TotalFare of type float
Public member functions
- A constructor to assign initial values as follows:
T_Code with the word “NULL”
No_of_Adults as 0
No_of_Children as 0
Distance as 0
TotalFare as 0 - A function AssignFare( ) which calculates and assigns the value of the data member TotalFare as follows:
For each Adult
For each child’s fare will be 50% of the fare mentioned in the above table,
e.g. If Distance = 750, No_of_Adults = 3 and No_of_Children 2
Then, TotalFare should be calculated as
No_of_Adults *300 + No_of_Children *150
i.e. 3 * 300 + 2 * 150 = 1200
- A function EnterTravel( ) to input the values of the data members T_Code, No_of_Adults, No_of_Children
and Distance and invoke the AssignFare( ) function. - A function ShowTravel() which displays the content of all the data members for a travel.
(d) Consider the following program and answer the questions (i) to (iv) given below:
class M { char Cname[25]; protected: char Hoffice[25]; public: M(); char Country[25]; void EnterData(); void DisplayData(); }; class B:public M { long NOE; char Ctry[25]; protected: void Association(); public: B(); void Add(); void Show(); }; class 0:publ ic B { char State[25]; public: O(); void Enter(); void Output(); };
(i) Which type of inheritance is shown in the above example?
I. Single Level Interitance
II. Multi-Level Inheritance
III. Multiple Inheritance
(ii) Wite the names of those data members which can be directly accessed from the objects of class O.
(iii) Write the names of those member functions, which can be directly accessed from the objects of class O.
(iv) Write the names of those data members, which can be directly accessed from the Add() function of class B.
Question 3.
(a) Suppose one-dimensional array AR containing integers are arranged in ascending order. Write a user-defined function in C++ to search for one integer from AR with the help of binary search method, returning an integer 0 to show absence of the number and integer 1 to show presence of the number in array. The function should have
three parameters (i) an array AR (ii) the number to be searched and (iii) the number of elements N in the array.
(b) An array Arr[15] [20] is stored in the memory along the row with each element occupying 4 bytes. Find out the base address and address of the element Arr[3] [2], if the element Arr[5] [2] is stored at the address 1500.
(c) Write a function ColProduct(int arr[ ][5], int M, int N) in C++ to print the product of each column of a two-dimensional integer array passed as the argument of the function.
e.g. If the two-dimensional array contains
Then, output should appear as
Product of Column 1 = 24
Product of Column 2 = 30
Product of Column 3 = 240
(d) Evaluate the following postfix notation of expression:
6, 5, 2, *, 10, 4, +, +, –
(e) Define function stackpop() to delete nodes, for a linked implemented stack having the following structure
for each node:
struct node { char name[20]; int age; node * Link; }; class Stack { node * top; public: Stack() { top=NULL; } void stackpush(); void stackpop(); };
Question 4.
(a) Given a file “stu.dat” with records of students of the following class and a C++ code accessing the file.
class Stu public: int roll; char name[20]; float marks; void Insert(); void Show(); }; void main() { fstream f; f.open("stu.dat",ios::binary | ios:: in); int pos; Stu s1; f.read((char*)&s1, sizeof(s1)); f.read((char*)&s1, sizeof(s1)); f.read((char*)&s1, sizeof(s1)); pos=f.tellg(); f.read((char*)&s1, sizeof(s1)); f.seekg(pos); cout<<s1.roll<<"\t"; puts(s1.name); cout<<"\t"<<s1.marks; f.close(); }
and file “stu.dat” contains data as following:
1 ekta 90
2 neeru 98
3 sam 87
4 ronit 76
5 seema 65
6 shruti 89
Write the output of the above code.
(b) Write a function to count number of vowels present in a text file named “VOWEL.TXT”.
e.g. If the content of the file fun.txt is as follows:
Arihant Publication
Computer Science
C++ Language
Programming
The function count() should display the following:
Number of vowels = 21
(c) Given a binary file “stu.dat”, containing records of following structure type:
class Stu { public: int roll no; char name[25]; char class[4]; float marks; char grade; void Insert(); void Show(); };
Write a function in C++ that would take an argument Roll number to be searched and print the record details.
SECTION B
Question 5.
(a) In a database, there are two tables COMPANY and PRODUCT as shown below:
If taken Cartesian product of the tables, i.e. COMPANY x PRODUCT, then
(i) What will be the cardinality of the resultant table?
(ii) What will be the degree of the resultant table?
(b) 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 INo, Name, Price from the table ITEM in descending order of Price.
(ii) To display the Name of all the items from the table ITEM who are purchased by store with code S01 or S02.
(iii) To display the ItemName and SName of those from the table STORE and ITEM whose location Nehru Place.
(iv) To display all the details from the table ITEM, which have price more than 7000.
(v) SELECT Location, COUNT(*) FROM STORE GROUP BY Location; (vi) SELECT SName, Location, Name, INo, Price FROM STORE, ITEM WHERE STORE.SNo=ITEM.SNO AND Name LIKE 'K%’; (vii) SELECT Name, Price*0.05 AS Discount FROM ITEM WHERE SNo IN('S02' , 'S03'); (viii) SELECT COUNT(DISTINCT Location) AS Loc, MAX(Price) AS Maximum, MIN(Price) AS Minimum FROM STORE, ITEM;
Question 6.
(a) Simplify the given Boolean expression algebraically.
F(X, Y, Z) = XZ + Z(\(\bar { X }\) + XY)
(b) Represent the Boolean expression (x + y)(y + z)(z + x) with the help of NOR gates only.
(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(P, Q, R, S) = Π (0, 2, 3, 5, 6, 7, 8, 10, 11, 12, 15)
Question 7.
(a) Write down the name of two transmission media for networking. Also, give one advantage of each.
(b) How does hub work?
(c) A company wants to form a network on its five computers to server within the company premises.
Is star topology suited for company? Why/why not?
(d) What are the various syntax elements of URL?
(e) SHIKSHA ACADEMY in Meerut is setting up the network between its different wings.
There are 4 wings named as SENIOR(S), JUNIOR(J), ADMIN(A) and HOSTEL(H).
Number of Computers
Number of Computers
(i) Suggest a suitable topology for networking the computer of all wings.
(ii) Name the wing, where the server is to be installed. Justify your answer.
(iii) Suggest the placement of hub/switch in the network.
(iv) Mention an economic technology to provide Internet accessibility to all wings.
(f) Differentiate between downloading and uploading.
(g) How can we prevent viruses from harming our systems?
Answers
Answer 1.
(a) (i) and (iv) are invalid C++ statements. Since, an assignment statement indicates that the value given by the expression on right hand side of assignment operator (=) must be stored in the variable named on its left hand side.
(b) (i) → cout() (ii) → cos () (c) const int n = 10: void main() { int A[n]={30, 25, 20, 15, 10}; for(int b=0; b<n; b++) { A[b]+=10; cout<<A[b]; } }
(d) Output
10
10
23
30
(e) Output
y = 7
z = 2
x = 13
y = 6
z = 3
y = 5
z = 2
x = 13
(f) The possible output will be (i) and (iv).
The minimum value of ToGo = 1
The maximum value of ToGo = 2
Answer 2.
Differences between Pass by value and Pass by reference are as follows:
Pass by value | Pass by reference |
Passes an argument by value. The procedure code does not have any access to the underlying element in the calling code. |
Passes an argument by reference. The procedure code gives a direct reference to the programming element in the calling code. |
e.g. //Pass by value illustration #include int square(int x) { return x*x; } int main() { int n=10; int ans; ans=square(n); cout<<"Answer is''<<ans; cout<<"Value of a is"<<n; return 0; }
//Illustration of Pass by reference #include void square(int *x) { *x=(*x)*(*x); } int main() { int n=10; square(&n); cout<<"Value of n is"<<n; return 0; }
(b) (i) Function1 will execute, when Statementl will be executed in the given code.
(ii) Salary L(S);
(c) class Travel { char T_Code[5]; int No_of_Adults; int No_of_Children; int Distance; float TotalFare; public: Travel() { strcpy(T_Code, "NULL"); No_of_Adults = 0; No_of_Children = 0; Distance=0; TotalFare=0; } void AssignFare() { float fare=0; if(Distance>=1000) fare=No_of_Adults*500+No_of_Children*250; else if(Distance>=500) fare=No_of_Adults*300+No_of_Children*150; else fare=No_of_Adults*200+No_of_Chi ldren*100; TotalFare=fare; } void EnterTravel() { cout<<"Enter value of travel code"; gets(T_Code); cout<<"Enter Number of Adults"; cin>>No_of_Adults; cout<<"Enter Number of Children"; cin>>No_of_Children; cout<<"Enter Distance"; cin>>Distance; AssignFare(); } void ShowTravel() { cout<<"Travel code:"; puts(T_Code); cout<<"Number of Adults:"<<No_of_Adults<<endl; cout<<"Number of Children:"<<No_of_Chi1dren<<endl; cout<<"Distance:"<<Distance<<endl; cout<<"Total Fare:"<<TotalFare<<endl; }
(d) (i) II. Multi Level Inheritance
(ii) Country [25],State[25]
(iii) EnterData(), DisplayData(), Add(), Show(), Enter(), Output()
(iv) NOE, Ctry[25], Hoffice[25], Country[25]
Answer 3.
(a) int bsearch(int AR[],int I, int N) { int beg=0, last=N-1, mid: while(beg <= last) { mid=(beg+last)/2; if(AR[mid]==I) return 1; // Element is present in array else if(I > AR[mid]) beg=mid+1; else last=mid-1; } return 0; // Element is absent in array }
(b) Total number of rows R = 15
Total number of columns C = 20
Lowest row
Ir = 0 Lowest column
Ic = 0 Size of element
W = 4 bytes
Arr[I][J], i.e. Arr[5][2] = 1500
Arrangement order = Row wise
Base address B = ?
Arr[I][J] = B + W*[C*(I – Ir) + (J – Ic)]
Arr[5][2] = B + 4* [20* (5 – 0) + (2 – 0)]
1500 = B + 4 * [100+2]
1500 = B + 408
B = 1092
Base address = 1092
Arr[I][J] = B + W * [C * {I – Ir) + (J – Ic)]
Arr[3][2] = 1092 + 4* [20* (3 – 0) + (2 – 0)]
= 1092 + 4* [60 + 2]
=1092 + 4* [62] = 1092 + 248
Arr[3][2] = 1340
(c) void ColProduct(int arr[][5], int M, int N) { int r, c, prod; for(c=0; c<N; c++) { prod =1; for(r=0; r<M; r++) prod *= arr[r][c]; cout<<"Product of Column "<<c+1<<" = "<<prod; cout<<endl; } }
(d) The expression is 6, 5, 2, *, 10, 4, +, +, –
Result = -18
(e) void Stack::stackpop() { if(top == NULL) , { cout<<"Stack underflow.": return; } node *temp = top; top = top->Link; delete temp; cout<<"node deleted."; }
Answer 4.
(a) Output
4 ronit 76
(b) void count() char ch; int noofvowels=0; ifstream ifs; ifs.open("VOWEL.TXT", ios::in | ios::binary); if(!ifs) { cout<<"file does not exit"; exit(0); } while(!ifs.eof()) { ifs.get(ch); tolower(ch); if(ch=='a' || ch='e' || ch='i' || ch='o' || ch=='u' ||ch='A' || ch=='E'||
ch=='I' ||ch=='0' || ch=='U') noofvowels++; } cout<<"Number of vowels = "<<noofvowels<<endl; } (c) void search(int rn) { Stu s1; char found = 'n'; ifstream fi("stu.dat",ios::in | ios::binary); while(fi.read((char*)&s1, sizeof(si))) { if (s1.roll no==rn) { cout<<s1.name<<"\t"<<s1.rollno<<"\t" <<s1.class<<"\t"<<s1.marks<<"\t"<<s1.grade<<endl; found = 'y'; break; } } if(found=='n') cout<<"Record not found"; fi.close(); }
Answer 5.
(a) (i) The cardinality of resultant table = 3 x 5 = 15
(ii) The degree of resultant table = 4 + 3 = 7
(b) (i) SELECT INo, Name, Price FROM ITEM WHERE ORDER BY Price DESC;
(ii) SELECT Name FROM ITEM WHERE SNo=’S01′ OR SNo=’S02′;
(iii) SELECT Name, SName FROM ITEM A, STORE B WHERE A, SNo=B.SNo AND Location=’Nehru Place’;
(iv) SELECT * FROM ITEM WHERE Price>7000;
Answer 6.
Answer 7.
(a) (i) Co-axial cable
(ii) Microwave
Advantage of co-axial cable is that it can be used for broadband transmission, i.e. several channels can be transmitted simultaneously.
Advantage of microwave transmission is that it offers ease of communication over difficult terrains.
(b) Hub forwards any data packets-including E-mail, Word processing documents, spreadsheets,
print requests etc., they receive over one port from one workstation to all of their remaining port.
(c) Yes, star topology will be suited for the company. Because, star topology uses one device
per connection and it is easy to access resources speedly.
(d) Following are the syntax elements of URL:
- The type of server or protocol (e.g. http or https).
- The name/address of the server on the Internet (e.g. www.google.com).
- The location of the file on the server (/login.jsp).
(e) (i) Star topology can be used for networking the computer of all wings.
(ii) The server should be installed in Wing S, as it has maximum number of computers and installing the
server in this wing will help to reduce the network traffic.
(iii) Hub/Switch will be required in all wings.
(iv) The economic way to provide Internet accessibility to all wings is to use the proxy server at Wing
S and connect to the Internet through a dial-up network.
(f) Downloading refers to transfer of files from FTP server to the user’s computer and uploading
refers to transfer of files from user’s computer onto FTP server.
(g) Following are the few of the many ways available to prevent viruses from harming our system:
- Never use a foreign disk or CD without scanning it for viruses.
- Install and use antivirus software.
- Keep antivirus software up-to-date.
- Always scan files before downloading them.
- Do not open an unknown person E-mail.
We hope the CBSE Sample Papers for Class 12 Computer Science Paper 4 help you. If you have any query regarding CBSE Sample Papers for Class 12 Computer Science Paper 4, drop a comment below and
we will get back to you at the earliest.