Professional Documents
Culture Documents
C++ Practical QP
C++ Practical QP
Table: INTERIORS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Red rose Double Bed 23-Feb-2006 32000 15
2 Soft touch Baby cot 20-Jan-2006 9000 10
3 Jerry‟s home Baby cot 19-Feb-2006 8500 10
4 Rough woof Office table 01-Jan-2006 20000 20
5 Comfort zone Double bed 12-Jan-2006 15000 20
6 Jerry look Baby cot 24-Feb-2006 7000 19
7 Lion king Office table 20-Feb-2006 16000 20
8 Royal tiger Sofa 22-Feb-2006 30000 25
9 Park sitting Sofa 13-Dec-2005 9000 15
10 Dine Paradise Dining Table 19-Feb-2006 11000 15
1. To show all information about the Sofa‟s from the interiors table.
2. To list the item name which are priced at more than 10000 from the interiors
table.
3. To display item name and date of stock of those items, in which the discount
percentage is more than 15 from interiors table.
4. To list item name and type of items, in which data of stock is before 22-Jan-
2002 from the interiors table in descending order of item name.
5. To count the number of items of each type from interiors table.
SET 2
5. To display the book id, book name and quantity issued for all books which have been
issued.
SET
Q1. Following is the structure of each record of a binary data file named
“COLONY.DAT”.
struct COLONY
{ char Colony_Code[10];
char Colony_Name[10];
int No_of_People;
};
Write a menu driven program using functions to
i) create a binary file “COLONY.DAT”
ii) display the contents of the file. (Name of the file to be taken as parameter.)
iii) to update the file with a new value of No_of_People. The value of
Colony_Code and No_of_People are to be read during the execution of
the program.
Table : BOOKS
BOOK_ID BOOK_NAME AUTHOR_NAME PUBLISHERS PRICE TYPE QUANTITY
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
F0001 The Tears William Hopkins First Publishers 650 Fiction 20
T0001 My First C++ Brains & Brroke EPB 350 Text 10
T0002 C++ A.M.Rossaine TDH 350 Text 15
Brainworks
F0002 Thunderbolts Anna Roberts First Publishers 750 Fiction 50
Table : ISSUED
BOOK_ID QUANTITY_ISSUED
T0001 4
C0001 5
F0001 2
1. To insert new row in the table issued having the following data:
„F3003‟, 1
2. To display the total no. of books (quantity) of each type.
3. To find the maximum price from books which have quantity more than 15.
4. To count unique publishers from books
5. To display the no. of titles available of each publishers.
SET 5
Q1 A chain of grocery store keeps the records of all its customers and their
dealings with the store. The records need to be kept in order and updated
as and when required. Consider the following class definition and perform
the following operations using separate functions:
Note : Write the required member function for the class
class store
{ int ID_No;
char Name[30]; char Address[40];
long Tel_No;
char Status; // „M‟ for Member and „N‟ for non-members
public:
long R_Tel_No() { return Tel_no;}
char R_status() { return Status;}
void Assign_Tel(long Tel) (Tel_No = Tel ;)
char* R_Name() { return Name ;}
};
Write a menu driven program with separate functions to perform the
following:
a. Create a file called “CUSTOMER.DAT” and write objects to it.
b. View all the records from the file where status is „M‟ (i.e.display records
of all the members).
c. Change the telephone number of a customer in his record by taking
the new number of the customer as an input.
d. Display the entire contents of the file.
Q1. Write a menu driven program using separate functions to perform the
following :
i) create a text file “STORY.TXT”
ii) display the contents of the file. (Name of the file to be taken as
parameter.)
iii) to count and display the number of lines not starting with alphabet „A‟
present in a text file “STORY.TXT”.
iv) to reverse each line of a text file and store it in “NEWFILE.TXT”. Display
the contents of the file “NEWFILE.TXT”
Table : PLAYER
PCODE NAME GCODE
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
Q1. Write a menu driven program using separate functions to perform the
following :
i) create a text file “HAPPY.TXT”
ii) display the contents of the file. (Name of the file to be taken as
parameter.)
iii) to count and display the number of lines starting with alphabet „T‟
present in a text file “HAPPY.TXT”.
iv) to reverse each line of a text file and store it in “NEWFILE.TXT”. Display
the contents of the file “NEWFILE.TXT”
Table STOCK
NO ITEMCODE QUANTITY DATEOFPURCHASE WARRANTY
1 C201 9 21-May-2005 2
2 P1010 3 21-May-2005 4
3 S203 1 29-Sep-2004 3
4 C201 2 13-Jun-2005 1
5 P1010 1 31-Oct-2004 2
6 U34 5 21-May-2005 1
7 P1010 2 11-Jan-2006 2
Table: ITEM
ITEMCODE ITEMNAME PRICE
C201 Computer 39000
P1010 Printer 11000
S203 Scanner 4500
WC05 Camera 1200
U34 UPS 1900
1. To select item purchased after 31-Jan-2005.
2. To list the item name in descending order of date of purchase where quantity
is more than three
3. To count number of Items (total quantity) whose cost is more than 10000.
4. To insert a new record in the table STOCK with following data:
8 C201 5 13-Jun- 1
2005
Q1 Declare a class STATE containing data members : name of the state and
its capital. Include member functions to read and display the data
members. Create a data file “STATE.DAT” containing objects of class
STATE. Write an interactive menu driven Object Oriented program to do
the following:
1. Append (create) records
2. Display all records
3. Determine the capital if the name of the state is known
4. To modify the capital in the same file for the state name input by
the user.
Table STOCK
NO ITEMCODE QUANTITY DATEOFPURCHASE WARRANTY
1 C201 9 21-May-2005 2
2 P1010 3 21-May-2005 4
3 S203 1 29-Sep-2004 3
4 C201 2 13-Jun-2005 1
5 P1010 1 31-Oct-2004 2
6 U34 5 21-May-2005 1
7 P1010 2 11-Jan-2006 2
Table: ITEM
ITEMCODE ITEMNAME PRICE
C201 Computer 39000
P1010 Printer 11000
S203 Scanner 4500
WC05 Camera 1200
U34 UPS 1900
1. To generate a report on each item code with the item name and total value
(quantity * Price).
2. To find average cost of all items with quantity more than 2 items.
3. To find average cost of items with date of purchase is before 1-Jan-2005.
4. To reduce the cost of all UPS by 100.
5. To delete all the records in the table STOCK.
SET
Q1 Following is the structure of each 1111 record of a binary data file named
“PLAYER.DAT”. struct PLAYER
{ char P_Code[10];
char P_Name[10];
int score; };
Write a menu driven program using functions to
i) create a binary file “PLAYER.DAT”
ii) display the contents of the file. (Name of the file to be taken as parameter.)
iii) to update the file with a new value of score for a given player code. The
values of P_Code and score are to be read during the execution of the
program.
Q2. Write SQL commands for the following:
TABLE: DOCTOR
ID NAME DEPT SEX EXPERIENCE
101 John ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 K George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3
111 Bill MEDICINE F 12
130 Morphy ORTHOPEDIC M 15
TABLE: SALARY
ID BASIC ALLOWANCE CONSULTATION
101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 100
109 42000 1700 200
105 18900 1690 300
130 21700 2600 300
1. Display NAME of all doctors who are in "MEDICINE" having more than 10 years
experience from the table DOCTOR.
2. Display the average salary of all doctors working in "ENT" department using the tables
DOCTOR and SALARY. Salary = BASIC + ALLOWANCE
3. Display the minimum ALLOWANCE of female doctors.
4. Display the highest consultation fee among all male doctors.
5. Display the number of records of female doctors
SET
1212
Q1 Consider the following class definition:
class Room
{ int R_Code;
char Department[30];
int Number;
public:
void get_data( )
{ cout << “Room Code :”; cin >> R_Code;
cout << “Department :”; gets(Department);;
cout << “Total Labs :”; cin >> Number;
}
void Disp_data( )
cout << “Room Code :”; << R_Code;
cout << “Department :”; << Department;;
cout << “Total Labs :”; << Number;
}
int Get_code( ) { return R_Code;}
};
Write a menu driven program using separate functions:
a) To create and append records to a binary file called “Rooms.dat”
b) To read the file the file and display it‟s contents.
c) To search for a record for a R_Code given by the user and replace
the record with a new record given by the user.
Q2. Write SQL commands for the following:
TABLE :CONSIGNOR
CnorID CnorName CnorAddress City
ND01 R Singhal 24,ABC Enclave New Delhi
ND02 Amit Kumar 123,Palm Avenue New Delhi
MU15 R Kohli 5/A,South Street Mumbai
MU50 S Kaur 27-K,Westend Mumbai
TABLE:CONSIGNEE
CneeID CnorID CneeName CneeAddress CneeCity
MU05 ND01 Rahul Kishore 5,Park Avenue Mumbai
ND08 ND02 P Dhingra 16/J,Moore Enclave New Delhi
KO19 MU15 A P Roy 2A,Central Avenue Kolkata
MU32 ND02 S Mittal P 245 AB Colony Mumbai
ND48 MU50 B P Jain 13,Block D,A Vihar New Delhi
Table :Sender
SenderID SenderName SenderAddress SenderCity
ND01 R Jain 2, ABC Appts New Delhi
MU02 H Sinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122 – K, SDA New Delhi
Table : Recipient
Table: INTERIORS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Red rose Double Bed 23-Feb-2006 32000 15
2 Soft touch Baby cot 20-Jan-2006 9000 10
3 Jerry‟s home Baby cot 19-Feb-2006 8500 10
4 Rough woof Office table 01-Jan-2006 20000 20
5 Comfort zone Double bed 12-Jan-2006 15000 20
6 Jerry look Baby cot 24-Feb-2006 7000 19
7 Lion king Office table 20-Feb-2006 16000 20
8 Royal tiger Sofa 22-Feb-2006 30000 25
9 Park sitting Sofa 13-Dec-2005 9000 15
10 Dine Paradise Dining Table 19-Feb-2006 11000 15
1. To show all information about the Sofa‟s from the interiors table.
2. To list the item name which are priced at more than 10000 from the interiors
table.
3. To display item name and date of stock of those items, in which the discount
percentage is more than 15 from interiors table.
4. To list item name and type of items, in which data of stock is before 22-Jan-
2002 from the interiors table in descending order of item name.
5. To count the number of items of each type from interiors table.
SET
1515
Q1. The following data items are to be stored for a student:
a) Stu_no
b) Stu_name
c) Percentage
Write an object oriented program to store the data for a student in a
STACK using LINKED implementation. Your program should have the
following member functions.
a) push()
b) pop()
c) display()
These functions are called as per the user‟s choice
Table: INTERIORS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Red rose Double Bed 23-Feb-2006 32000 15
2 Soft touch Baby cot 20-Jan-2006 9000 10
3 Jerry‟s home Baby cot 19-Feb-2006 8500 10
4 Rough woof Office table 01-Jan-2006 20000 20
5 Comfort zone Double bed 12-Jan-2006 15000 20
6 Jerry look Baby cot 24-Feb-2006 7000 19
7 Lion king Office table 20-Feb-2006 16000 20
8 Royal tiger Sofa 22-Feb-2006 30000 25
9 Park sitting Sofa 13-Dec-2005 9000 15
10 Dine Paradise Dining Table 19-Feb-2006 11000 15
Table : BOOKS
Table : ISSUED
BOOK_ID QUANTITY_ISSUED
T0001 4
C0001 5
F0001 2
1. To show book name, author name and price of books of First Publishers.
2. To list the names from books of Text type.
3. To display the names and price from books in ascending order of their price.
4. To increase the price of all books of EPB publishers by 10%.
5. To display the book id, book name and quantity issued for all books which
have been issued.
SET
1717
Q1 A QUEUE is to be created using circular array implementation, each element
of the queue having the following information
a) Roll number of the student
b) Age of the student
Front and Rear are two variables that indicate the position of the first and
the last element. Write the following functions;
a) QINSERT( ) -to add an element in to the QUEUE. [Check for overflow]
b) QDELETE( )-to remove an element from QUEUE [check for underflow]
c) QDISPLAY( )-to display all elements of the QUEUE.
Write a complete object oriented menu driven program to implement the QUEUE.
Table : BOOKS
BOOK_ID BOOK_NAME AUTHOR_NAME PUBLISHERS PRICE TYPE QUANTITY
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
F0001 The Tears William Hopkins First Publishers 650 Fiction 20
T0001 My First C++ Brains & Brroke EPB 350 Text 10
T0002 C++ A.M.Rossaine TDH 350 Text 15
Brainworks
F0002 Thunderbolts Anna Roberts First Publishers 750 Fiction 50
Table : ISSUED
BOOK_ID QUANTITY_ISSUED
T0001 4
C0001 5
F0001 2
1. To insert new row in the table issued having the following data:
„F3003‟, 1
2. To display the total no. of books (quantity) of each type.
3. To find the maximum price from books which have quantity more than 15.
4. To count unique publishers from books
5. To display the no. of titles available of each publishers.
SET
1818
Table : GAMES
Table : PLAYER
1. To display the names of all games where schedule data is after 31-Dec-2005.
2. To display the name of the players in the table player with their gamesname.
3. To display the content of the games table in ascending order of scheduledate.
4. To display the sum of prize money received by players in the table games.
5. To add a new column (attribute) ADDRESS of type Char(20) in the table
PLAYER.
SET
1919
Q1. Each node of a QUEUE contains the following information along with a
pointer which stores the address of the next node.
a) Roll number of the student.
b) Age of the student
FRONT & REAR are pointers pointing to the first and last node of the
QUEUE. Write the following function.
a) QINSERT()-To insert a node in the QUEUE which is allocated
dynamically
b) QDELETE( ) – To remove a node from the QUEUE and release the
memory
c) QDISPLAY( ) – To display the QUEUE
Write a complete menu driven object oriented program to implement the
above.
Table : GAMES
GCODE GAMENAME NUMBER PRIZEMONEY SCHEDULEDATE
101 Carom Board 2 5000 23-Jan-2006
102 Badminton 2 12000 12-Dec-2005
103 Table Tennis 4 8000 14-Feb-2006
105 Chess 2 9000 01-Jan-2006
108 Lawn Tennis 4 25000 19-Nov-2005
Table : PLAYER
PCODE NAME GCODE
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
Table : HOSPITAL
NO NAME AGE D_CODE DATOFADM CHARGES SEX
1 Sandeep 65 D101 23-Feb-2006 300 M
2 Ravina 24 D105 20-Jan-2006 200 F
3 Karan 45 D105 19-Feb-2006 200 M
4 Tarun 12 D101 01-Jan-2006 300 M
5 Zubin 36 D108 12-Jan-2006 250 M
6 Ketaki 16 D108 24-Feb-2006 300 F
7 Ankita 29 D120 20-Feb-2006 800 F
8 Zareen 45 D115 22-Feb-2006 300 F
9 Kush 19 D120 13-Jan-2006 800 M
10 Shailya 31 D125 19-Feb-2006 400 F
Table : DEPARTMENT
D_CODE DEPARTMENT DOCTOR
D101 Surgery Dr.D.Nayar
D105 Orthopedic Dr.M.Roy
D108 ENT Dr.K.Bhatia
D115 Gynecology Dr.P.Tejpal
D120 Cardiology Dr.D.Singh
D125 Nuvlear Medicine Dr.A.Banerjee
Table : HOSPITAL
NO NAME AGE D_CODE DATOFADM CHARGES SEX
1 Sandeep 65 D101 23-Feb-2006 300 M
2 Ravina 24 D105 20-Jan-2006 200 F
3 Karan 45 D105 19-Feb-2006 200 M
4 Tarun 12 D101 01-Jan-2006 300 M
5 Zubin 36 D108 12-Jan-2006 250 M
6 Ketaki 16 D108 24-Feb-2006 300 F
7 Ankita 29 D120 20-Feb-2006 800 F
8 Zareen 45 D115 22-Feb-2006 300 F
9 Kush 19 D120 13-Jan-2006 800 M
10 Shailya 31 D125 19-Feb-2006 400 F
Table : DEPARTMENT
D_CODE DEPARTMENT DOCTOR
D101 Surgery Dr.D.Nayar
D105 Orthopedic Dr.M.Roy
D108 ENT Dr.K.Bhatia
D115 Gynecology Dr.P.Tejpal
D120 Cardiology Dr.D.Singh
D125 Nuvlear Medicine Dr.A.Banerjee
Table STOCK
NO ITEMCODE QUANTITY DATEOFPURCHASE WARRANTY
1 C201 9 21-May-2005 2
2 P1010 3 21-May-2005 4
3 S203 1 29-Sep-2004 3
4 C201 2 13-Jun-2005 1
5 P1010 1 31-Oct-2004 2
6 U34 5 21-May-2005 1
7 P1010 2 11-Jan-2006 2
Table: ITEM
ITEMCODE ITEMNAME PRICE
C201 Computer 39000
P1010 Printer 11000
S203 Scanner 4500
WC05 Camera 1200
U34 UPS 1900
Table STOCK
NO ITEMCODE QUANTITY DATEOFPURCHASE WARRANTY
1 C201 9 21-May-2005 2
2 P1010 3 21-May-2005 4
3 S203 1 29-Sep-2004 3
4 C201 2 13-Jun-2005 1
5 P1010 1 31-Oct-2004 2
6 U34 5 21-May-2005 1
7 P1010 2 11-Jan-2006 2
Table: ITEM
ITEMCODE ITEMNAME PRICE
C201 Computer 39000
P1010 Printer 11000
S203 Scanner 4500
WC05 Camera 1200
U34 UPS 1900
1. To generate a report on each item code with the item name and total value
(quantity * Price).
2. To find average cost of all items with quantity more than 2 items.
3. To find average cost of items with date of purchase is before 1-Jan-2005.
4. To reduce the cost of all UPS by 100.
5. To delete all the records in the table STOCK.
SET
TABLE: DOCTOR
ID NAME DEPT SEX EXPERIENCE
101 John ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 K George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3
111 Bill MEDICINE F 12
130 Morphy ORTHOPEDIC M 15
TABLE: SALARY
ID BASIC ALLOWANCE CONSULTATION
101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 100
109 42000 1700 200
105 18900 1690 300
130 21700 2600 300
1. Display NAME of all doctors who are in "MEDICINE" having more than 10 years
experience from the table DOCTOR.
2. Display the average salary of all doctors working in "ENT" department using the tables
DOCTOR and SALARY. Salary = BASIC + ALLOWANCE
3. Display the minimum ALLOWANCE of female doctors.
4. Display the highest consultation fee among all male doctors.
5. Display the number of records of female doctors
SET 25
Table :Sender
SenderID SenderName SenderAddress SenderCity
ND01 R Jain 2, ABC Appts New Delhi
MU02 H Sinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122 – K, SDA New Delhi
Table : Recipient