Академический Документы
Профессиональный Документы
Культура Документы
CHANDIGARH REGION
Computer Science (083) Pre-Board – I
(2017-18)
1|P a ge
e) What is the minimum and maximum value that can be assigned to the variable R in the
following program: (2)
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize( );
int Num , R ;
cin >> Num ; // Assume user entered the value as 10
R = random (Num) + 5 ;
for (int I = 0 ; I<= R ; I++)
{
cout << N<< “:” ;
}
}
f) Find the output of the following program - (3)
#include<iostream.h>
void pass(int *ptr)
{
for(int *pt=ptr ; pt<ptr+2 ;pt++)
cout<<*pt<<'-';
cout<<endl;
}
void main()
{
int box = {10,33,17,12,20};
pass(box);
pass(box+1);
pass(&box[2]);
}
Que. 2 Answer the following questions:
a) What do you understand by data abstraction and data hiding? How they are implemented in
C++? (2)
b) Answer the questions (i) and (ii) after going through the following class: (2)
class WORK
{
int WorkID;
char WorkType;
public:
~WORK( ) // Function 1
{
cout<<”Un-Allocated”<<endl;
}
void status( ) // Function 2
{
cout<<WorkID<<”;”<<WorkType<<endl;
}
2|P a ge
WORK( ) // Function 3
{
WorkID=10;
WorkType=’T’;
}
WORK(WORK&W) // Function 4
{
WorkID=W.WorkID+12;
WorkType=W.WorkType+1;
}
};
(i) Which member function out of function1, function2, function3 and function4 shown in the
above example of class WORK is called automatically, when the scope of an object gets over?
What is it called?
(ii) Write the C++ statement that would invoke function3 and function 4.
c) Define a class TravelPlan in C++ with the following description: (4)
Private Members:
PlanCode of type long
Place of type string
NOT(No_of_Travellers) of type integer
NOB(No of Buses) of type integer
Public Members:
A constructor to assign initial values of PlanCode as 1001, Place as "Agra", NOT as 5, NOB
as 1
A function NewPlan() which allows users to enter PlanCode, Place and NOT. The function
assigns the value of NOB as per the following conditions:
Number of Travellers Number of Buses
Less than 20 1
Equal to or more than 20 and less than 40 2
Equal to 40 or more than 40 3
A function ShowPlan() to display the content of all the data members.
d) Answer the questions (i) to (iv) based on the following: (4)
class FacetoFace
{
char CenterCode[10];
public:
void Input( );
void Output( );
};
class Online
{
char Website[50];
public:
void Sitein( );
void Siteout( );
};
class Training : public FacetoFace, private Online
{
long Tcode;
3|P a ge
float Charge;
int Period;
public:
void Register( );
void Show ( );
};
(i) Which type of inheritance is shown in the above example?
(ii) Write names of all member functions accessible from Show( ) function of class Training.
(iii) Write names of all the members accessible through an object of class Training.
(iv) Is the function Output( ) accessible inside the function Siteout( )? Justify you answer.
a) Write a C++ function to sort any array of n elements using insertion sort. Array should be
passed as argument to the function. (2)
b) An array T[50][20] is stored in the memory along the column with each element occupying 4
bytes. Find out the base address and address of element T[30][15], if an element T[25][10] is
stored at the memory location 9800. (3)
c) Write a code in C++ for the Push and Pop functions of a dynamically allocated Stack
containing name of cities. (4)
Assume the following definition of node.
struct node
{
char city[30];
node *link;
};
d) Write a C++ function to print both the diagonal of a square matrix. e.g. (3)
Then the output should be:
2 3 5
Diagonal 1: 2 3 3
1 3 6
9 4 3 Diagonal 2: 5 3 9
e) Evaluate the following postfix expression using a stack and show the contents of the stack after
each operation. (2)
100, 40, 8, +, 20, 10, -, +, *
Que. 4 Answer the following questions:
a) Differentiate between read() and write() function in terms of file handling? (1)
b) Write a function in C++ which opens a text file Sample.txt and count the number of lines
present in the file and displays it. (2)
c) A binary file “ADDRESS.DAT”, containing records of the following class colony type. (3)
class colony
{
char c_no[10];
char c_name[40];
long no_of_ppl;
4|P a ge
public:
void getdata( )
{
gets(c_no);
gets(c_name);
cin>>no_of_ppl;
}
void showdata( )
{
cout<<”Colony Number : “<<c_no;
cout<<”Colony Name : “<<c_name;
cout<<” No. of people : “<<no_of_ppl;
}
char * returnname( )
{
return c_name;
}
};
Write a function showaddress( ) in C++ that would read contents of file “ADDRESS.DAT” and
display the details of those colonies where number of people are greater than 1000.
c) Write the Boolean Expressions for the following Logic Circuit. (1)
d) Obtain the simplified form of the Boolean Expression using K’ Map: (3)
F( x , y , z, w) = ∑ (0,2,4,5,8,9,12,13,15)
5|P a ge
b) Consider the following tables Stationery and Consumer. Write SQL commands for the
statement (i) to (iv) and give outputs for SQL queries (v) to (viii). (6)
Table: Stationery
S_ID StationeryName Company Price
DP01 Dot Pen ABC 10
PL02 Pencil XYZ 6
ER05 Eraser XYZ 7
PL01 Pencil CAM 5
GP02 Gel Pen ABC 15
Table: Consumer
C_ID ConsumerName Address S_ID
01 Good Learner Delhi PL01
06 Write Well Mumbai GP02
12 Topper Delhi DP01
15 Write & Draw Delhi PL02
16 Motivation Banglore PL01
6|P a ge
Main Resource
Building Building
Accounts
Training
Building
Building
Center to center distances between various buildings as per architectural drawings (in meters) is
as follows:
Main Building 15
Resource Building 25
Training Building 250
Accounts Building 10
(i) Suggest a cable layout of connection between the buildings.
(ii) Suggest the most suitable place (i.e building) to house the server of this Educational
Content Provider Company. Also provide a suitable reason for your suggestion.
(iii) Suggest the placement of the following devices with justification:
i. Repeater
ii. Hub/Switch
(iv) The Company is planning to connect its International office situated in Noida. Which
out of following wired communication links, will you suggest for very high speed
connectivity?
i) Wi-Fi ii) Optical Fibre iii) Ethernet Cable
7|P a ge