0% found this document useful (0 votes)
66 views8 pages

CS Mock (3) 2020-01-12: (I) Puts (Ii) Randomize (Compartment-2009)

This document contains a mock test paper with multiple choice and written answer questions related to C++ programming. It includes questions about: 1) Defining arrays and pointers, header files for standard functions, and identifying errors in a C++ program. 2) Overloaded functions, copy constructors, class definitions. 3) Functions to calculate sums, modify arrays, find memory addresses, delete nodes from a queue, and convert expressions to postfix notation. 4) Functions to count words in a file and display records from a binary file based on a field value.

Uploaded by

Betensor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views8 pages

CS Mock (3) 2020-01-12: (I) Puts (Ii) Randomize (Compartment-2009)

This document contains a mock test paper with multiple choice and written answer questions related to C++ programming. It includes questions about: 1) Defining arrays and pointers, header files for standard functions, and identifying errors in a C++ program. 2) Overloaded functions, copy constructors, class definitions. 3) Functions to calculate sums, modify arrays, find memory addresses, delete nodes from a queue, and convert expressions to postfix notation. 4) Functions to count words in a file and display records from a binary file based on a field value.

Uploaded by

Betensor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

CS Mock(3) 2020-01-12

Q.1. (a) Define array and pointer. 2 [Compartment-2002]


(b) Write names of the header files to which the following belong: (1)
(i) puts() (ii) randomize() [Compartment-2009]
(c) Will the following program execute successfully? If no, state the reason (s). (2)
#include<stdio.h>
void main ()
{
int x,sum = 0;
cin<<n;
for(x=1, x<100, x += 2)
if x % 2 == 0
sum += x;
cout>>"SUM" >>sum;
} [Out Side Delhi-2000]
(d) Find the output of the following program: (3)
#include <iostream.h>
struct score
{ int Year;
float Topper;
};
void Change(Score *S, int x=20)
{
S->Topper =(S->Topper +25) - x ;
S->Year ++;
}
void main()
{
Score Arr[] ={{2007,100},{2008,95}};
Score * Point =Arr;
Change(Point , 50 );
cout<< Arr[0].Year<<'#'<< Arr[0].Topper<< endl;
Change(++Point) ;
cout<< Point->Year<<'#'<< Point->.Topper<< endl;
} [Compartment-2009]
(e) Find and write the output of the following C++ program code : 2
Note : Assume all required header files are already included in the program.
#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
void main()
{
int A , B, NUM[] = {10,23,14,54,32};
for(int CNT =4; CNT>0; CNT--)
{
A=NUM[CNT];
B=NUM[CNT-1];
cout<<Diff(A,B)<<'#';
}
} [Out Side Delhi-2017]
(f) Observe the following program SCORE.CPP carefully, If the value Num entered by the
user is 5, choose the correct possible output(s) from the options from (i) to (iv), and justify
your option. (2) [Delhi Board-2005]
//Program : SCORE.CPP
#include <iostream.h>
#include <stdlib.h>
void main()
{ randomize();
int Num, Rndnum;
cin >> Num ;
Rndnum = random(Num) + 5 ;
for( int N=1; N<=Rndnum ; N++)
{
cout<< N <<" " ;
}
}
(i) 1 2 3 4 (ii) 1 2
(iii) 1 2 3 4 5 6 7 8 9 (iv) 1 2 3
Q.2. (a) Which function(s) out of the following can be considered as overloaded function(s)
in the same program? Also, write the reason for not considering the other(s) as overloaded
function (s). 2 [Question Bank-2000]
void Test( int X=5); // Function 1
void Test(int X, float Y =3.14 ); // Function 2
void Test(int X =10, float Y=3.14); // Function 3
void Test(int &x); // Function 4
int Test(); // Function 5
int Test(int x); // Function 6
(b) What is a copy constructor? Give a suitable example in C++ to illustrate with its
definition within a class and a declaration of an object with the help of it. 2
[Delhi Board-2015]
(c) Write the definition of a class GRAPH in C++ with the following descriptions: 4
Private members:
XUnit // integer
YUnit // integer
Type // char array of size 20
AssignType() /* Member function to assign value of Type based upon
XUnit and YUnit as follows : */

Condition Type
XUnit = 0 Or YUnit = 0 None
XUnit is more than YUnit Bar
XUnit is less than or equal to YUnit Line
Public members:
InXY() /* Function to allow user to enter values of XUnit and YUnit and
then invoke AssignType() to assign value of type */
OutXY() /* Function to display XUnit ,YUnit and Type */
[Out Side Delhi-2019]
(d) Answer the questions (i) to (iv) based on the following : 4
class First
{
int X1;
protected:
float X2;
public:
First();
void Enter1();
void Display1();
};

class Second : private First


{
int Y1;
protected:
float Y2;
public:
Second();
void Enter2();
void Display();
};

class Third : public Second


{
int Z1;
public:
Third();
void Enter3();
void Display();
};

void main()
{
Third T; //Statement 1
__________________; //Statement 2
}

i)Which type of Inheritance out of the following is illustrated in the above example?
-Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
ii)Write the names of all the member functions, which are directly accessible by the object T
of class Third as declared in main() function.
iii) Write Statement 2 to call function Display() of class Second from the object T of class
Third.
iv) What will be the order of execution of the constructors, when the object T of class Third
is declared inside main()? [Out Side Delhi-2017]
Q.3. (a) Write a definition for a function SUMMIDCOL(int MATRIX[][10],int N,int M) in
C++, which finds the sum of the middle column’s elements of the MATRIX (Assuming N
represents number of rows and M represents number of columns, which is an odd integer).
Example: if the content of array MATRIX having N as 5 and M as 3 is as follows: (2)
1 2 1
2 1 4
3 4 5
4 5 3
5 3 2

The function should calculate the sum and display the following:
Sum of Middle Column: 15 [Out Side Delhi-2017]

(b) Write the definition of a function Modify(int A[], int N) in C++, which should reposition
the content after swapping each adjacent pair of numbers in it. (3) [Compartment-2015]
[NOTE : ASSUMING the size of array is multiple of 4 ]
for example, If array of 8 integers is as follows
A[0] A[1] A[ 2] A[3] A[4] A[ 5] A[6] A[7]
86 93 40 36 52 21 70 10
After executing the functions, the array content should be changed as follows:
A[0] A[1] A[ 2] A[3] A[4] A[ 5] A[6] A[7]
40 36 86 93 70 10 52 21

(c) Let us assume P[20][30] is a two-dimensional array, which is stored in the memory along
the column with each of its elements occupying 2 bytes, find the address of the element
P[3][5], if the address of the array is 45000. 3
OR
Let us assume P[10][20] is a two-dimensional array, which is stored in the memory along the
row with each of its elements occupying 2 bytes, find the address of the element P[5][10], if
the address of the element P[2][15] is 25000. [Compartment-2019]

(d) Write a function in C++ to delete a Node containing customer's information, from
dynamically allocated Queue of customers with the help of the following structure : (4)
struct Customer
{
int CNo;
char CName[20] ;
Customer *Link ;
} ; [Out Side Delhi-2007]

(e) Convert the expression (True && False) OR NOT(False OR True) to postfix
expression. Show the contents of the stack at every step. (2) [Delhi Board-2001]

Q.4. (a) Write a function in C++ to count the words "this" and "these" present in a text file
"ARTICLE.TXT". (2)
[Note that the words "this" and "these" are complete words] [Delhi Board-2010]
(b) Write a definition for function ONOFFER() in C++ to read each object (3)
of a binary file TOYS.DAT, find and display details of those toys, which has status as “ON
OFFER”. Assume that the file TOYS.DAT is created with the help of objects of class TOYS,
which is defined below :
class TOYS
{
int TID;
char Toy[20],Status[20];
float MRP;
public:
void Getinstock()
{
cin>>TID;
gets (Toy);
gets(Status);
cin>>MRP;
}
void View()
{
cout<<TID<<":"<<Toy<<":"<<MRP<<":"<<Status<<endl;
}
char *SeeOffer(){return Status;}
}; [Out Side Delhi-2016]

(c) Observe the program segment given below carefully and answer the question that
follows : (1)
class Labrecord
{
int Expno ;
char Experiment [ 20 ];
char Checked ;
int Marks ;

public:
// Function to enter Experiment details
void EnterExp();
// Function to display Experiment details
void ShowExp();
// Function to return Expno
char RChecked(){return Checked ; }
// Function to assign marks
void AssignMarks( int M )
{
Marks = M ;
}
};
void ModifyMarks( )
{
fstream File;
File.open("MARKS.DAT" , ios::binary |ios::in | ios::out );
Labrecord L ;
int Rec = 0 ;
while(File.read((char *)&L, sizeof(L)))
{
if(L.RChecked() == 'N' )
L.Assignmarks(0) ;
else
L.Assignmarks(10) ;
____________________ ; //statement 1
____________________ ; //statement 2
Rec++ ;
}
File.close();
}
if the function ModifyMarks() is suppose to modify Marks for the record in the file
MARKS.DAT based on their statusof member Checked (Containing value either 'Y' or 'N').
Write C++ statements for the statement 1 and statement 2, where statement 1 is required to
position the file write pointer to an appropriate place in the file and statement 2 is to perform
the write operation with the modified record. [Out Side Delhi-2007]
Q.5. (a) Observe the following table A and B carefully and write the name of the RDBMS
operation out of
(i) INTERSECT (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT,
which has been used to produce the output as shown in RESULT ?Also, find the Degree
and Cardinality of the RESULT. (2) [Question Bank-2001]

Table A
column 1 column 2
A A
A B

Table B
column 1 column 2
A A
A C

RESULT
column 1 column 2
A A
(b) Consider the following relations MobileMaster & MobileStock:- 6
MobileMaster
M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 4500 2013-02-12
MB003 Nokia N1100 2250 2011-04-15
MB004 Micromax Unite3 4500 2016-10-17
MB005 Sony XperiaM 7500 2017-11-20
MB006 Oppo SelfieEx 8500 2010-08-21
MobileStock
S_Id M_Id M_Qty M_Supplier
S001 MB004 450 New Vision
S002 MB003 250 Praveen Gallery
S003 MB001 300 Classic Mobile Store
S004 MB006 150 A-one Mobiles
S005 MB003 150 The Mobile
S006 MB006 50 Mobile Centre
Write the SQL query for questions from (i) to (iv) & write the output of SQL command for
questions from (v) to (viii) given below:-
(i) Display the Mobile company, Mobile name & price in descending order of their
manufacturing date.
(ii) List the details of mobile whose name starts with ‘ S ’ .
(iii) Display the Mobile supplier & quantity of all mobiles except ‘MB003’.
(iv) To display the name of mobile company having price between 3000 & 5000.
(v) SELECT M_Id, SUM(M_Qty) FROM MobileStock GROUP BY M_Id;
(vi) SELECT MAX(M_Mf_Date), MIN(M_Mf_Date) FROM MobileMaster;
(vii) SELECT M1.M_Id, M1.M_Name, M2.M_Qty, M2.M_Supplier FROM MobileMaster
M1, MobileStock M2 WHERE M1.M_Id=M2.M_Id AND M2.M_Qty>=300;
(viii) SELECT AVG(M_Price) FROM MobileMaster; [Question Bank-2018]
Q.6. (a) Verify X'Y + X.Y' + X'Y' = (X' + Y' ) using truth table. (2) [Delhi Board-2009]
(b) Write the equivalent Boolean Expression for the following Logic Circuit : (2)

[Out Side Delhi-2010]


(c) Derive a Canonical SOP expression for a Boolean function G, represented by the
following truth table : (1)
U V W F (U,V,W)
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0

[Delhi Board-2017]
(d) Reduce the following Boolean Expression using K-Map : (3)
F(A,B,C,D) = ∑(0,1,2,3,4,5,10,11,15) [Out Side Delhi-2005]
Q.7. (a) Write one name of wireless and one wired communication medium. 2
[Compartment-2017]
(b) Dr. Theekkar Singh is a very experienced orthopaedician in the Ilaj Nagar City. He is
planning to connect 5 of his clinics of the city with a personalised application for his
appointment organization without using mobile/web application. Which out of the following
networks would be suitable ? 1
(i)PAN (ii) LAN (iii)MAN (iv)WAN [Compartment-2019]
(c) What do you understand by a backbone of a network? (1)
OR what is CLOUD COMPUTING? [Delhi Board-2001]
(d) Expand the following terminologies : (2)
i) XML ii) WWW iii) WLL iv) TCP/IP [Out Side Delhi-2007]
(e) INSTITUTE OF DISTANCE LEARNING is located in PUNE and is planing to go in for
four wings for better interaction. The details are as shown below : (4) [Compartment-2009]

Student Lib
Wing Wing

Admission Admin
Wing Wing

Distance between various Wings :


Student to Admin 150 m
Student To Admission 100 m
Student to LIB 325 m
Admission to Admin 100 m
Admission to LIB 125 m
Admin To Lib 90 m
Number of Computers in each of the Wings :
Student Wing 225
Admission Wing 50
Admin Wing 10
LIB Wing 25
(e1) Suggest the type of networking(LAN , WAN, MAN) for connecting
LIB Wing to Admin Wing. Justify your answer.
(e2) Suggest the most suitable place (i.e. Wing) to house the server with a suitable reason.
(e3) Suggest the placement of following devices with reason :
(i) Repeater (ii ) Switch
(e4) 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.

You might also like