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

Following C++ Code: (1) (Compartment-2008)

The question provides code snippets and asks questions related to C++ programming concepts like classes, functions, arrays, files etc. Part a defines a class Medical with data members like representative code, name and mobile. It asks to fill blanks with appropriate functions - one to input details and other to display all details. Part b asks to write a function to read objects from a binary file PHOTOS.DAT and display total number of photos of type PORTRAIT, assuming class PHOTOS is defined to contain photo code and type. Part c provides a class definition and function skeleton to update mobile number by reading from a file and searching using representative number, asking to complete the code.

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)
72 views8 pages

Following C++ Code: (1) (Compartment-2008)

The question provides code snippets and asks questions related to C++ programming concepts like classes, functions, arrays, files etc. Part a defines a class Medical with data members like representative code, name and mobile. It asks to fill blanks with appropriate functions - one to input details and other to display all details. Part b asks to write a function to read objects from a binary file PHOTOS.DAT and display total number of photos of type PORTRAIT, assuming class PHOTOS is defined to contain photo code and type. Part c provides a class definition and function skeleton to update mobile number by reading from a file and searching using representative number, asking to complete the code.

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_4_2020-01-14

Q.1. (a) Define Macro with suitable example. 2 [Question Bank-2016]


(b) Write the names of the header file, which is/are essentially required to run/execute the
following C++ code: (1) [Compartment-2008]
void main()
{
char Text[]="Computer";
cout<<setw(15)<< Text ;
}
(c) Find syntax error(s) if any, in the following program. (2)
include <iostream.h>
void main()
{
int P[]={90,10,24,15};Q,Number=4;
Q=9;
for[int I=Number-1 ; I>0; I--]
switch(I)
{
case 0:
case 3: cout<<P[I]*Q<<endl; break;
case 1:
case 2: cout>>P[I] + Q ;
}
} [Out Side Delhi-2003]
(d) Find and write the output of the following C++ program code: 2
Note: Assume all required header files are already being included in the program.
void Convert(char *P1, char *P2)
{
char *Q;
Q=P2;
P2=P1;
P1=Q;
cout<<P1<<"*"<<P2<<endl;
}
void main()
{
char S1[]="One", S2[]="Two";
Convert(S1,S2);
cout<<S1<<"&"<<S2<<endl;
} [Compartment-2019]
(e) Find the output of the program assuming all the required header files have
been included : (3) [Out Side Delhi-2002]
int X(int &A, int &B)
{
A = A + B;
B = A - B;
A = A - B;
}
void main()
{
int a = 4, b = 18 ;
X(a,b);
cout<< a << "," << b ;
}
(f) Observe the following C++ code and find the possible output(s) from the options (i) to
(iv) following it. Also, write the minimum and maximum values that can possibly be
assigned to the variable End. 2 [Compartment-2019]
Note: . Assume all required header files are already being included in the program.
.The function random(N) generates any possible integer between 0 and N-1(both
values included).
void main()
{
randomize();
int A[]={5,10,15,20,25,30,35,40};
int Start = random(2) + 1;
int End = Start + random(4);
for(int I=Start; I<=End, I++)
cout<<A[I]<<”*”;
}
(i) 20*25*30*35* (ii) 15*20*25*30*
(iii) 5*15*20 (iv) 10*15*20*25*30*
Q.2. (a) Define the following terms: (i) Inheritance (ii) Encapsulation. (2)
[Delhi Board-1998]
(b) 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 Fun(int B=20); // Function 1
void Fun(float A,int B=1.0); // Function 2
int Fun(float A,float B=5.5); // Function 3
void Fun(); // Function 4
void Fun(int &KA); // Function 5
void Fun(float &c); // Function 6
(c) Write the definition of a class CITY in C++ with following description . 4
Private Members [Out Side Delhi-2016]
- Ccode //Data member for City Code (an integer )
- CName //Data member for City Name (a string)
- Pop //Data member for population (a long int)
- Km //Data member for Area Coverage (a float )
- Density //Data member for Population Density (a float)
- DenCal() //A member function to calculate Density as Pop/KM
Public Members
- Record() //A function to allow user to enter values of
//Ccode, Name,Pop,KM and call DenCal() function
- View() //A function to display all the data members
//also display a message "Highly Populated City"
//if the Density is more than 10000
(d) Consider the following and answer the questions given below : (4)[Compartment-2000]
class ALPHA
{
int x,y;
protected :
void putvalA();
public:
void getvalA();
};
class BETA: private ALPHA
{
int m,n;
protected :
void getvalB();
public:
void putvalB();
};
class GAMMA : protected BETA
{
int a;
public :
void getdata();
void showdata();
};
i. Write the names of members functions ,which are accessible from the objects of class
GAMMA.
ii. Write name of data members,which are accessible from the member functions of class
BETA.
iii. Name the base class and derived class of class BETA.
iv. Name the private member functions of class GAMMA.

Q.3. (a) Write a function in C++, Which accepts an integer array and its size as
arguments/parameters and then assigns the elements into a two dimensional array of integers
in the following format: (3) [Delhi Board-2006]
If the array is 1,2,3,4,5,6 if the array is 1,2,3
The resultant 2D array is given below The resultant 2D array is given below

1 2 3 4 5 6 1 2 3
1 2 3 4 5 0 1 2 0
1 2 3 4 0 0 1 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0
(b) Write a function in C++ to which accepts a 2D array of integers and its size as
arguments and displays the elements of middle row and elements of middle column.
[Assuming the 2D array to be square matrix with odd dimension i.e. 3x3, 5x5, 7x7 etc....]
Example :- If the array content is (2)
3 5 4
7 6 9
2 1 8
Output through the function should be :
Middle Row : 7 6 9
Middle Column : 5 6 1 [Out Side Delhi-2007]
(c) An array X[20][10] is stored in the memory with each of the elements requiring 8 bytes
of storage. if the base address of X is 6000, determine memory location of X[16][16] and
X[10][2] , if the array is stored along the Column. (3) [Compartment-2003]

(d) Write a function QUEDEL( ) in C++ to display and delete an element from dynamically
allocated Queue containing nodes of the following given structure: (4)
struct NODE
{
int Itemno ;
char Itemname [20] ;
NODE *Link;
} ; [Out Side Delhi-2009]
(e) Evaluate the following postfix expression showing status of stack after execution of each
step : (2) [Compartment-2000]
10, 40, +, 8, 2, +, *, 10 , -
Q.4. (a) Polina Raj has used a text editing software to type some text in an article. After
saving the article as MYNOTES.TXT, she realised that she has wrongly typed alphabet K
in place of alphabet C everywhere in the article. Write a function definition for
PURETEXT() in C++ that would display the corrected version of the entire article of the
file MYNOTES.TXT with all the alphabets “K” to be displayed as an alphabet “C” on screen
Note: Assuming that MYNOTES.TXT does not contain any C alphabet otherwise.
Example:
If Polina has stored the following content in the file MYNOTES.TXT: (3)
I OWN A KUTE LITTLE KAR. I KARE FOR IT AS MY KHILD.
The function PURETEXT() should display the following content:
I OWN A CUTE LITTLE CAR. I CARE FOR IT AS MY CHILD.
[Out Side Delhi-2017]

(b) Write a definition for function COUNTPICS ( ) in C++ to read each object of a binary
file PHOTOS.DAT, find and display the total number of PHOTOS of type PORTRAIT.
Assume that the file PHOTOS.DAT is created with the help of objects of class PHOTOS,
which is defined below: 2 [Out Side Delhi-2017]
class PHOTOS
{
int PCODE;
char PTYPE[20]; // Photo Type as “PORTRAIT”,”NATURE”
public:
void ENTER()
{
cin>>PCODE;gets(PTYPE);
}
void SHOWCASE()
{
cout<<PCODE<<":"<<PTYPE<<endl;
}
char *GETPTYPE(){return PTYPE;}
};

(c) Fill in the blanks marked as Statement 1 and Statement 2, in the program
segment given below with appropriate functions for the required task. 1
class Medical
{
int RNo; //Representative Code
char Name [20]; //Representative Name
char Mobile [12]; //RepresentativeMobile
public:
void Input(); //Function to enter all details
void Show(); //Function to display all details
int RRno(){return RNo;}
void ChangeMobile() //Function to change Mobile
{
cout<< "Changed Mobile:";
gets(Mobile); .
}
} ;
void RepUpdate ()
{
fstream F;
F.open("REP.DAT",ios::binary|ios::in|ios::out};
int Change=0;
int URno;
cout<<"Rno(Rep No-to update Mobile):";
cin>>URno;
Medical M;
while(!Change && F.read((char*)&M,sizeof(M)))
{ if(M.Rrno()==URno)
{
//Statement l:To call the function to change Mobile No.
_________________________________ ;
//Statement 2:To reposition file pointer to re-write
//the updated object back in the file
_________________________________ ;
F.write((char*)&M,sizeof(M));
Change++ ;
}
}
if (Change)
cout<<"Mobile Changed for Rep "<<URno«endl;
else .
cout<<"Rep not in the Medical"<<endl;
F.close () ;
} [Delhi Board-2014]

Q.5. (a) Observe the following table CANDIDATE carefully and write the name of the
RDBMS operation out of
(i) SELECTION (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.
TABLE: CANDIDATE (2) [Delhi Board-2017]
NO NAME STREAM
C1 AJAY LAW
C2 ADITI MEDICAL
C3 ROHAN EDUCATION
C4 RISHAB ENGINEERING
TABLE RESULT
NO NAME
C3 ROHAN

(b) Consider following tables FLIGHTS and FARES and Write SQL commands for
statements (i) to (iv) and give output for SQL queires (v) to (vi) : (6)
Table :STAFF
FL_NO STARTING ENDING NO_FLIGHT NO_STOPS
IC301 MUMBAI DELHI 8 0
IC799 BANGLORE DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 0
AM812 KANPUR BANGLORE 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI TRIVENDURUM 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
Table:FARE
FL_NO AIRLINES FARE TAX
IC701 Indian Airlines 6500 10
MU499 sahara 9400 5
AM501 Jet Airways 13450 8
IC899 Indian Airlines 8300 4
IC302 Indian Airlines 4300 10
IC799 Indian Airlines 10500 10
MC101 Deccan Airlines 3500 4
(i) Display FL_NO AND NO_FLIGHTS from “KANPUR” to ”BANGLORE” from the
table FLIGHTS.
(ii) Arrange the contents of the table FK=LIGHT in the ascending
(iii) Display the FL_NO and Fare to be paid for the flight from DELHI to MUMBAI using
the table FLIGHTS and FARE, where the fare to be paid = FARE + FARE * TAX%/100
(iv) Display the minimum fare “Indian Airlines” is offering from the table FARE.
(v) SELECT FL_NO,NO_FLIGHTS,AIRLINES from FLIGHTS, FARE where
STARTING =”DELHI” and FLIGHT.FL_NO=FARE.FL_NO;
(vi) SELECT count(Distinct ENDING) from FLIGHTS; [Out Side Delhi-2006]

Q.6. (a) State De Morgan's law. Verify one of the De Morgan's Law using truth table. (2)
[Out Side Delhi-2000]

(b) Write the equivalent Boolean expression for the following Logic Circuit: (2)

[Out Side Delhi-2005]


(c) Write the Product of Sum form of the function H(U,V,W), truth table representation of H
is as follows: [Delhi Board-1998]
U V W H
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1

(d) (d) Reduce the following Boolean Expression using K-Map: 3


F(A,B,C,D)= ∑(0,1,2,4,5,6,8,10) [Question Bank-2010]

Q.7. (a) Damodar Mohan has been informed that there had been a backdoor entry to his
company, which has provided access to his system through a malicious user/programs,
allowing confidential and personal information to be subjected to theft, it happened
because he clicked a link provided in one of the pop-ups frm a website announcing him to
be winner of price worth 1 Million Dollers. Which of the following has caused this out of
the following? 2
i) Virus ii) Worm iii) Trojan Hourse
Also, mention , what he should do to prevent this infection. [Out Side Delhi-2019]

(b) Give two applicationsof Web 2.0. 1 [Compartment-2016]

(c) Select two server side scripting languages out of the following ? 1[Compartment-2019]
(i) ASP (ii) VBScript (iii) JavaScript (iv) PHP

(d) Write the expanded names for the following abbreviated terms used in Networkingand
Communications: 2 [Question Bank-2018]
(i) FOSS (ii)GPRS (iii)GSM (iv) WLL

(e) Indian School, in Mumbai is starting up the network between its different wings. There
are Four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as shown below.: [4]

The distance between various buildings is as follows:


ADMIN TO SENIOR 200m
ADMIN TO JUNIOR 150m
ADMIN TO HOSTEL 50m
SENIOR TO JUNIOR 250m
SENIOR TO HOSTEL 350m
JUNIOR TO HOSTEL 350m
Number of Computers in Each Building
SENIOR 130
JUNIOR 80
ADMIN 160
HOSTEL 50
(b1) Suggest the cable layout of connections between the buildings.
(b2) Suggest the most suitable place (i.e. building) to house the server of this School,
provide a suitable reason.
(b3) Suggest the placement of the following devices with justification.
· Repeater
· Hub / Switch
(b4) The organization also has Inquiry office in another city about 50-60 Km away in
Hilly Region. Suggest the suitable transmission media to interconnect to school and Inquiry
office out of the following .
· Fiber Optic Cable
· Microwave
· Radio Wave

[Question Bank-2015]

You might also like