Advertisements
Advertisements
Write the output of the following C++ program code :
Note: Assume all required header files are already being included in the program.
void Location(int &X,int Y=4)
{
Y+=2;
X+=Y;
}
void main()
{
int PX=l0,PY=2;
Location(PY);
cout<<PX<<","<<PY<<endl;
Location(PX,PY);
cout<<PX<<", "<<PY<<endl;
}Concept: Concept of Object Oriented Programming in C++
Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
class Eval
{
char Level;
int Point;
public:
Eval(){Level='E'; Point=O;}
void Sink(int L)
{
Level~=L;
}
void Float(int L)
{
Level+=L;
Point++;
}
void Show()
{
cout<<Level<<"#"<<Point<<endl;
}
};
void main ()
{
Eval E;
E.Sink(3);
E.Show();
E.Float(7);
E.Show();
E.Sink(2);
E.Show();
}Concept: Concept of Object Oriented Programming in C++
Study the following program and select 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 VAL
Note:
-Assume all required header files are already being included in the program.
- random(n) function generates all integer 6, and n-1.
void main ()
{
randomize();
int VAL;
VAL=random(3)+2;
char GUESS[] ="ABCDEFGHIJK";
for(int I = 1, I = 1;I <= VAL; I++)
{
for (int J=VAL; J<= 7; J++)
cout<<GUESS[J];
cout<<endl;
}
}
1)

2)

3)

4)

Concept: Concept of Object Oriented Programming in C++
What is a copy constructor?
Concept: 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.
Concept: Class and Object in C++
Observe the following C++ code and answer the questions (i) and (ii):
class Passenger
{
long PNR;
char Name[20];
public:
Passenger () · //Function 1
{ cout<<"Ready"<<endl; }
void Book(long P,char N[]) //Function 2
{ PNR = P; strcpy(Name, N);}
void Print () //Function 3
{ cout«PNR << Name <<endl; }
-Passenger() //Function 4
{ cout<<"Booking cancelled! "<<endl;}
};
1) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code:
void main()
{
Passenger P;
_________ //Line 1
_________ //Line 2
}//Ends here
2) Which function will be executed at } // Ends here? What is this function referred as?
Concept: Member of a Class - Data Members and Member Functions (Methods)
Write the definition of a class Photo In C++ with the following description:
Private Members
- Pno //Data member for Photo Number (an integer)
-Category //Data.member for Photo Category (a string)
- Exhibit I // Data member for Exhibition Gallery (a string)
- FixExhibit //A member function to assign Exhibition Gallery as per Category as shown in the following table
| Category | Exhibit |
| Antique | Zaveri |
| Modern | Johnsen |
| Classic | Terenida |
Public Members
-Register() //A function to allow user to enter values Pno I category and call FixExhibi t () function
- ViewAll() //A function to display all the data members
Concept: Member of a Class - Data Members and Member Functions (Methods)
Answer the questions (i) to (iv) based on the following:
class Interior
{
int Orderid;
char Address[20];
protected:
float Advance;
public:
Interior();
void Book(); void View();
};
class Painting:public Interior
{
int Wall,Area,ColorCode;
protected:
char Type;
public:
Painting();
void PBook();
void PView();
};
class Billing : public Painting
{
float Charges;
void Calculate();
public:
Billing();
void Bill();
void BillPrint();
};
1) Which type of Inheritance out of the following is illustrated in the above example?
- Single Level Inheritance
- Multi-Level Inheritance
- Multiple Inheritance
2) Write the names of all the data members, which are directly accessible from the member functions of class Painting.
3) Write the names of all the member functions, which are directly accessible from an object of class Billing.
4) What will be the order of execution of the constructors, when an object of class Billing is declared?
Concept: Inheritance in C++
Write the definition of a function Change(int P[], int N) in C++, which should change all the multiples of 10 in the array to 10 and rest of the elements as 1. For example, if an array of 10 integers is as follows:
| P[0] | P[1] | P[2] | P[3] | P[4] | P[5] | P[6] | P[7] | P[8] | P[9] |
| 100 | 43 | 20 | 56 | 32 | 91 | 80 | 40 | 45 | 21 |
After executing the function, the array content should be changed as follows:
| P[0] | P[1] | P[2] | P[3] | P[4] | P[5] | P[6] | P[7] | P[8] | P[9] |
| 10 | 1 | 10 | 1 | 1 | 1 | 10 | 10 | 1 | 1 |
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias
Write the definition of a member function PUSH( ) in C++, to add a new book in a dynamic stack of BOOKS considering the following code is already included in the program
struct BOOKS
{
char ISBN[20], TITLE[80];
BOOKS *Link;
};
class STACK
{
BOOKS *Top;
public:
STACK-() {Top=NULL;}
void PUSH();
void POP();
~STACK();
};Concept: Member of a Class - Data Members and Member Functions (Methods)
Write function definition for TOWER() in C++ to read the content of a text file WRITEUP.TXT, count the presence of word TOWER and display the number of occurrences of this word.
Note:
- The word TOWER should be an independent word
- Ignore type cases (i.e. lower/upper case)
Example:
If the content of the file WRITEUP.TXT is as follows:
| Tower of hanoi is an interesting problem. Mobile phone tower is away from here. Views from EIFFEL TOWER are amazing. |
The function TOWER( ) should display the following :
| 3 |
Concept: ifstream, ofstream, Classes
Write the definition of a function SumEO(int VALUES[], int N) in C++, which should display the 4 sum of even value and sum of odd values of the array separately.
Example: If the array VALUES contains
| 25 | 20 | 22 | 21 | 53 |
Then the functions should display the output as:
Sum of even values = 42 (i.e., 20+22)
Sum of odd values= 99 (i.e., 25+21+53)
Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
Write a definition for a function UpperHalf(int Mat[4][4]) in C++ which displays the elements in the same way as per the example is shown below.
For example, if the content of the array Mat is as follows:
| 25 | 24 | 23 | 22 |
| 20 | 19 | 18 | 17 |
| 15 | 14 | 13 | 12 |
| 10 | 9 | 8 | 7 |
Thew function should display the content in the following format:

Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
Let us assume Data[20][15] 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 Data(10][5], if the element Data[10][l5] is stored at the memory location 15000.
Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
Wnte the definition of a member function AddPac ket() for a class QUEUE in C++, to remove/delete a Packet from a dynamically allocated QUEUE of Packets' considering the following code is already written as a part of the program.
struct Packet
{
int PID;
char Address[20];
Packet *LINK;
};
class QUEUE
{
Packet *Front, *Rear;
public:
QUEUE(){Front=NULL;Rear=NULL;}
void AddPacket();
void DeletePacket();
~QUEUE();
};Concept: Queue (Array and Linked Implementation)
ARR[15] ft:20] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 .bytes. Find the .address of the element ARR[5)[15], if the element ARR[lO] [5] is stored at the memory location 35000.
Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
A two-dimensional array ARR[50][20] is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR[30] [10], if the element ARR[10] [5] is stored at the memory location 15000.
Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
Write a function REVROW(int P[] [5], int N, int M) in C++ to display the content of a two-dimensional array, with each row content in reverse order.
For example, if the content of the array is as follows:
| 15 | 12 | 56 | 45 | 51 |
| 13 | 91 | 92 | 87 | 63 |
| 11 | 23 | 61 | 46 | 81 |
The function should display output as

Concept: One and Two Dimensional Arrays - Sequential Allocation and Address Calculation
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii) which are based on the table.
TABLE: Account
| ANO | ANAME | ADDRESS |
| 101 | Nirja Singh | Bangalore |
| 102 | Rohan Gupta | Chennai |
| 103 | Ali Reza | Hyderabad |
| 104 | Rishabh Jain | Chennai |
| 105 | Simran Kaur | Chandigarh |
TABLE: TRANSACT
| TRNO | ANO | AMOUNT | TYPE | DOT |
| T001 | 101 | 2500 | Withdraw | 2017-12-21 |
| T002 | 103 | 3000 | Deposit | 2017-06-01 |
| T003 | 102 | 2000 | Withdraw | 2017-0S-12 |
| T004 | 103 | 1000 | Deposit | 2017-10-22 |
| T005 | 101 | 12000 | Deposit | 2017-11-06 |
1) To display details of all transaction of TYPE Depos1t from Table TRANSACT.
2) To display the ANO and AMOUNT of all Depos1ts and Withdrawals done in the month of October 2017 from table TRANSACT.
3) To display the last date of the transaction (DOT) from the table TRANSACT for the Accounts having ANO as 103
4) To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and TRANSACT who have done transactions less than or equal to 3000?
5) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN ('CHENNAI', 'BANGALORE');
6) SELECT DISTINCT ANO FROM TRANSACT
7) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT GROUP BY AND HAVING COUNT(*) > 1;
8) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT WHERE DOT <= '2017-06-01'
Concept: Structured Query Language Advantages of Using SQL
Observe the following table MEMBER 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 :
MEMBER
| NO | MNAME | STREAM |
| M001 | JAYA | SCIENCE |
| M002 | ADITYA | HUMANITIES |
| M003 | HANSRAJ | SCIENCE |
| M004 | SHIVAK | COMMERCE |
RESULT
| NO | MNAME | STREAM |
| M002 | ADI'l'YA | HUMANITIES |
Concept: Structured Query Language Advantages of Using SQL
