PRACTICAL LIST FOR CLASS XII
1. Define a class HOTEL in C++ with the following description:
Private Members
- Rno //Data Member to store Room No
- Name //Data Member to store customer Name
- Tariff //Data Member to store per day charge
- NOD //Data Member to store Number of days
- CALC //A function to calculate and return amount as NOD*Tariff and if the value of NOD*Tariff is more than 10000 then as 1.05*NOD*Tariff
Public Members:
Checkin( ) //A function to enter the content RNo,Name, Tariff and NOD
Checkout() //A function to display Rno, Name, Tariff, NOD
and Amount (Amount to be displayed by calling function CALC( )
2. Define a class Applicant in C++ with following description:
Private Members
- A data member ANo ( Admission Number) of type long
- A data member Name of type string
- A data member Agg(Aggregate Marks) of type float
- A data member Grade of type char
- A member function GradeMe( ) to find the Grade as per the Aggregate Marks obtained by a student. Equivalent Aggregate marks range and the respective Grades are shown as follows
Aggregate Marks Grade
> = 80 A
Less than 80 and > = 65 B
Less than 65 and > = 50 C
Less than 50 and > = 33 D
Less than 33 E
Public Members
- A function Enter( ) to allow user to enter values for ANo, Name, Agg & call function GradeMe( ) to find the Grade
- A function Result ( ) to allow user to view the content of all the data members.
3. Assume a text file “coordinate.txt” is already created. Using this file create a C++ function to count the number of words having first character capital.
4. Function to count number of lines from a text files (a line can have maximum 70 characters or ends at ‘.’)
5. C++ program, which initializes a string variable to the content “There is an island of opportunity in the middle of every difficulty.” and output the string one character at a time to the disk file “OUT.TXT”.
6. Write a function in a C++ to count the number of uppercase alphabets, alphabats, digits, white spaces and vowels present in a text file “BOOK.txt”
7. Assume a text file “Test.txt” is already created. Using this file, write a function to create three files “LOWER.TXT” which contains all the lowercase vowels and “UPPER.TXT” which contains all the uppercase vowels and “DIGIT.TXT” which contains all digits.
8. Write a function in C++ to count the no. of “He”, or “She” words present in a text file “story.txt”.If the file “story.txt” content is as follows:
He is playing in the ground. She is
playing with her dolls.
The output of the function should be
Count ofHe/She in file is: 2
9. Write a function in C++ to search for camera from a binary file “CAMERA.DAT” containing the objects of class CAMERA (as defined below). The user should enter the ModelNo and the function should search and display the details of the camera.
class CAMERA
{long ModelNo; float MegaPixel; int Zoom; Char Details[120];
public:
void Enter() { cin>>ModelNo>>MegaPixel>>Zoom; gets(Details); }
void Display(){ cout<<ModelNo<<MegaPixel<<Zoom<<Details<<endl; }
long GetModelNo() { return ModelNo; }
10. Write a function COPYABC() in C++, that would copy all those records having areacode as “123” from TELEPHONE.DAT to TELEBACK.DAT
11. Write a Get2From1() function in C++ to transfer the content from one array ALL[ ] to two different arrays Odd[ ] and Even[ ]. The Odd[ ] array should contain the values from odd positions(1,3,5,….) of ALL[ ] and Even[ ] array should contain the values from even positions (0,2,4,…) of ALL[ ].
Example: If the ALL array contains 12,34,56,67,89,90 the Odd[ ] array should contain 34, 67,90 and the Even[ ] array should contain 12,56,89
12. Write a DSUM() function in C++ to find sum of Diagonal Elements from a NxN Matrix. (Assuming that the N is a odd number)
13. Write a function in C++ which accepts an integer array and its size as arguments and replaces elements having even values with its half and elements having odd values with twice its value
14. Write a function in C++ which accepts an integer array and its size as argument and exchanges the value of first half side elements with the second half side elements of the array.
Example: If an array of eight elements has initial content as 2,4,1,6,7,9,23,10. The function should rearrange the array as 7,9,23,10,2,4,1,6.
15. Write a function in c++ to find and display the sum of each row and each column of 2 dimensional array. Use the array and its size as parameters with int as the data type of the array.
16. Write a function in C++, which accepts an integer array and its size as parameters and rearrange the array in reverse.
Example if an array of five members initially contains the elements as 6,7,8,13,9,19
Then the function should rearrange the array as 19,9,13,8,7,6
17. Write a function in C++, which accept an integer array and its size as arguments and swap the elements of every even location with its following odd location.
Example : if an array of nine elements initially contains the elements as 2,4,1,6,5,7,9,23,10 Then the function should rearrange the array as 4,2,6,1,7,5,23,9,10
18. Write function SORTPOINTS() in c++ to sort an array of structure Game in descending order of points using Bubble Sort Note: Assume the following definition of structure Game
struct Game
{long PNo; // Player Number
char PName[20];
long points;};
19. Write a c++ function to shift all the negative numbers to left and positive number in the right side.
20. Define a function SWPCOL() in C++ to swap ( interchange) the first column elements with the last column elements, for a two dimensional array passed as the argument of the function.
Example : if the two dimensional array contains
2 1 4 9
1 3 7 7
5 8 6 3
7 2 1 2
After swapping of the content of 1st and last column, it should be
9 1 4 2
7 3 7 1
3 8 6 5
2 2 1 7
21. Write the function to find the largest and second largest number from a two dimensional array. The function should accept the array and its size as argument.
22. Write a function in C++ to merge the contents of two sorted arrays A & B into third array C. Assuming array A is sorted in ascending order, B is sorted in descending order, the resultant array is required to be in ascending order.
23. Write a function in C++ to perform Delete operation on a dynamically allocated Queue containing Members details as given in the following definition of NODE:
struct NODE
{long Mno; //Member Number
char Mname[20]; //Member Name
NODE *Link;};
24. Define functions in C++ to perform a PUSH and POP operation in a dynamically allocated stack considering the following :
struct Node
{ int X,Y;
Node *Link; };
class STACK
{ Node * Top;
public:
STACK( )
{TOP=NULL;}
void PUSH( );
void POP( );
~STACK( ); };
25. Write a function in C++ to perform a Add and Delete operation in a dynamically allocated Queue considering the following:
struct node
{
int empno ;char name[20] ;float sal ;
Node *Link;
};
Q1 Write SQL commands for (i) to (viii) on the basis of relations given below:
BOOKS
book_id Book_name author_name Publishers Price Type qty
k0001 Let us C Sanjay mukharjee EPB 450 Comp 15
p0001 Genuine J. Mukhi FIRST PUBL. 755 Fiction 24
m0001 Mastering c++ Kanetkar EPB 165 Comp 60
n0002 Vc++ advance P. Purohit TDH 250 Comp 45
k0002 Near to heart Sanjeev FIRST PUBL. 350 Fiction 30
ISSUED
Book_ID |
Qty_Issued |
L02 |
13 |
L04 |
5 |
L05 |
21 |
i. To show the books of FIRST PUBL Publishers written by P.Purohit.
ii. To display cost of all the books written for FIRST PUBL.
iii. Depreciate the price of all books of EPB publishers by 5%.
iv. To display the BOOK_NAME,price of the books whose more than 3 copies have been issued.
v. To show total cost of books of each type.
vi. To show the detail of the most costly book.
Q2. Write SQL commands for (a) to (f) and write output for (g) on the basis of PRODUCTS relation given below:
PRODUCT TABLE
PCODE PNAME COMPANY PRICE STOCK MANUFACTURE WARRANTY
P001 TV BPL 10000 200 12-JAN-2008 3
P002 TV SONY 12000 150 23-MAR-2007 4
P003 PC LENOVO 39000 100 09-APR-2008 2
P004 PC COMPAQ 38000 120 20-JUN-2009 2
P005 HANDYCAM SONY 18000 250 23-MAR-2007 3
a) To show details of all PCs with stock more than 110.
b) To list the company which gives warranty for more than 2 years.
c) To find stock value of the BPL company where stock value is sum of the products of price and stock.
d) To show number of products from each company.
e) To count the number of PRODUCTS which shall be out of warranty on 20-NOV-2010.
f) To show the PRODUCT name which are within warranty as on date.
g). Give the output of following statement.
(i) Select COUNT(distinct company) from PRODUCT.
(ii) Select MAX(price)from PRODUCT where WARRANTY<=3
3.
Table : SchoolBus
Rtno |
Area_overed |
Capacity |
Noofstudents |
Distance |
Transporter |
Charges |
1 |
Vasant kunj |
100 |
120 |
10 |
Shivamtravels |
100000 |
2 |
Hauz Khas |
80 |
80 |
10 |
Anand travels |
85000 |
3 |
Pitampura |
60 |
55 |
30 |
Anand travels |
60000 |
4 |
Rohini |
100 |
90 |
35 |
Anand travels |
100000 |
5 |
Yamuna Vihar |
50 |
60 |
20 |
Bhalla Co. |
55000 |
6 |
Krishna Nagar |
70 |
80 |
30 |
Yadav Co. |
80000 |
7 |
Vasundhara |
100 |
110 |
20 |
Yadav Co. |
100000 |
8 |
Paschim Vihar |
40 |
40 |
20 |
Speed travels |
55000 |
9 |
Saket |
120 |
120 |
10 |
Speed travels |
100000 |
10 |
Jank Puri |
100 |
100 |
20 |
Kisan Tours |
95000 |
- To show all information of students where capacity is more than the no of student in order of rtno.
- To show area_covered for buses covering more than 20 km., but charges less then 80000.
- To show transporter wise total no. of students traveling.
- To show rtno, area_covered and average cost per student for all routes where average cost per student is - charges/noofstudents.
- Add a new record with following data:
(11, “ Moti bagh”,35,32,10,” kisan tours “, 35000)
- Give the output considering the original relation as given:
(i) select sum(distance) from schoolbus where transporter= “ Yadav travels”;
(ii) select min(noofstudents) from schoolbus;
(iii) select avg(charges) from schoolbus where transporter= “ Anand travels”;
- select distinct transporter from schoolbus;
4.
TABLE : GRADUATE
S.NO |
NAME |
STIPEND |
SUBJECT |
AVERAGE |
DIV. |
1 |
KARAN |
400 |
PHYSICS |
68 |
I |
2 |
DIWAKAR |
450 |
COMP. Sc. |
68 |
I |
3 |
DIVYA |
300 |
CHEMISTRY |
62 |
I |
4 |
REKHA |
350 |
PHYSICS |
63 |
I |
5 |
ARJUN |
500 |
MATHS |
70 |
I |
6 |
SABINA |
400 |
CEHMISTRY |
55 |
II |
7 |
JOHN |
250 |
PHYSICS |
64 |
I |
8 |
ROBERT |
450 |
MATHS |
68 |
I |
9 |
RUBINA |
500 |
COMP. Sc. |
62 |
I |
10 |
VIKAS |
400 |
MATHS |
57 |
II |
- List the names of those students who have obtained DIV 1 sorted by NAME.
- Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a year assuming that the STIPEND is paid every month.
- To count the number of students who are either PHYSICS or COMPUTER SC graduates.
- To insert a new row in the GRADUATE table: 11,”KAJOL”, 300, “computer sc”, 75, 1
(e) Give the output of following sql statement based on table GRADUATE:
- Select MIN(AVERAGE) from GRADUATE where SUBJECT=”PHYSICS”;
- Select SUM(STIPEND) from GRADUATE WHERE div=2;
- Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
- Select COUNT(distinct SUBDJECT) from GRADUATE;
(f) Assume that there is one more table GUIDE in the database as shown below:
Table: GUIDE
MAINAREA |
ADVISOR |
PHYSICS |
VINOD |
COMPUTER SC |
ALOK |
CHEMISTRY |
RAJAN |
MATHEMATICS |
MAHESH |
g) What will be the output of the following query:
SELECT NAME, ADVISOR FROM GRADUATE,GUIDE WHERE SUBJECT= MAINAREA;
5. Write SQL command for (i) to (vii) on the basis of the table SPORTS
Table: SPORTS
Student NO |
Class |
Name |
Game1 |
Grade |
Game2 |
Grade2 |
10 |
7 |
Sammer |
Cricket |
B |
Swimming |
A |
11 |
8 |
Sujit |
Tennis |
A |
Skating |
C |
12 |
7 |
Kamal |
Swimming |
B |
Football |
B |
13 |
7 |
Venna |
Tennis |
C |
Tennis |
A |
14 |
9 |
Archana |
Basketball |
A |
Cricket |
A |
15 |
10 |
Arpit |
Cricket |
A |
Atheletics |
C |
- Display the names of the students who have grade ‘C’ in either Game1 or Game2 or both.
- Display the number of students getting grade ‘A’ in Cricket.
- Display the names of the students who have same game for both Game1 and Game2.
- Display the games taken up by the students, whose name starts with ‘A’.
- Assign a value 200 for Marks for all those who are getting grade ‘B’ or grade ‘A’ in both Game1 and Game2.
- Arrange the whole table in the alphabetical order of Name.
- Add a new column named ‘Marks’.
6. Write SQL command for (i) to (vii) on the basis of the table Employees & EmpSalary
Table: Employees
Empid |
Firstname |
Lastname |
Address |
City |
010 |
Ravi |
Kumar |
Raj nagar |
GZB |
105 |
Harry |
Waltor |
Gandhi nagar |
GZB |
152 |
Sam |
Tones |
33 Elm St. |
Paris |
215 |
Sarah |
Ackerman |
440 U.S. 110 |
Upton |
244 |
Manila |
Sengupta |
24 Friends street |
New Delhi |
300 |
Robert |
Samuel |
9 Fifth Cross |
Washington |
335 |
Ritu |
Tondon |
Shastri Nagar |
GZB |
400 |
Rachel |
Lee |
121 Harrison St. |
New York |
441 |
Peter |
Thompson |
11 Red Road |
Paris |
Table: EmpSalary
Empid |
Salary |
Benefits |
Designation |
010 |
75000 |
15000 |
Manager |
105 |
65000 |
15000 |
Manager |
152 |
80000 |
25000 |
Director |
215 |
75000 |
12500 |
Manager |
244 |
50000 |
12000 |
Clerk |
300 |
45000 |
10000 |
Clerk |
335 |
40000 |
10000 |
Clerk |
400 |
32000 |
7500 |
Salesman |
441 |
28000 |
7500 |
Salesman |
Write the SQL commands for the following :
- To show firstname,lastname,address and city of all employees living in paris
- To display the content of Employees table in descending order of Firstname.
- To display the firstname,lastname and total salary of all managers from the tables Employee and empsalary , where total salary is calculated as salary+benefits.
- To display the maximum salary among managers and clerks from the table Empsalary.
Give the Output of following SQL commands:
- Select firstname,salary from employees ,empsalary where designation = ‘Salesman’ and Employees.empid=Empsalary.empid;
- Select count(distinct designation) from empsalary;
- Select designation, sum(salary) from empsalary group by designation having count(*) >2;
- Select sum(benefits) from empsalary where designation =’Clerk’;
7. (a) What do you understand by Selection and Projections in relational algebra ?
Consider the following table EMPLOYEE and salgrade and answer (b) and (c) part of the Question:
Table: EMPLOYEE
ECODE |
NAME |
DESIG |
SGRADE |
DOJ |
DOB |
101 |
Abdul Ahmad |
EXECUTIVE |
S03 |
23-Mar-2003 |
13-Jan-1980 |
102 |
Ravi Chander |
HEAD-IT |
S02 |
12-Feb-2010 |
22-Jul-1987 |
103 |
John Ken |
RECEPTIONIST |
S03 |
24-Jan-2009 |
24-Feb-1983 |
104 |
Nazar Ameen |
GM |
S02 |
11-Aug-2006 |
03-Mar-1984 |
105 |
Priyam Sen |
CEO |
S01 |
29-Dec-2004 |
19-Jan-1982 |
Table:SALGRADE
SGRADE |
SALARY |
HRA |
S01 |
56000 |
18000 |
S02 |
32000 |
12000 |
S03 |
24000 |
8000 |
(b) Write SQL commands for the following statements:
(i) To display the details of all EMPLOYEES in descending order of DOJ.
(ii) To display NAME and DESIG of those EMPLOYEES whose SALGRADE is either S02 or SO3.
(iii) To display the content of all the EMPLOYEES table, whose DOJ is in between 09-Feb-2006 and 08-Aug-2009.
(iv) To add a new row with the following
109, ‘Harish Roy’, ‘HEAD-IT’, ‘S02’,’09-Sep-2007’, ’21-Apr-1983’
(c) Give the output of the following SQL queries :
(i) SELECT COUNT(SGRADE), SGRADE FROM EMPLOYEE GROUP BY SGRADE;
(ii) SELECT MIN(DOB), MAX(DOJ) FROM EMPLOYEE;
(iii) SELECT NAME,SALARY FROM EMPLOYEE E, SALGRADE S
WHERE E.SGARDE=S.SGRADE AND E.ECODE<103;
(iv) SELECT SGRADE, SALARY+HRA FROM SALGRADE WHERE SGRADE=’S02’