Upload
vivek-chauhan
View
220
Download
0
Embed Size (px)
Citation preview
7/31/2019 c++new
1/17
C++ Assignment
:-VIVEK CHAUHAN
:- XII-A
7/31/2019 c++new
2/17
Index
S.NO PROGRAM REMARK
1 Program to add distance type object into thirdone.
2 Program to define employee class in c++.
3 Program to represent batsmen in a cricketteam.
4 Program to create the student pass fail data.
5 Program for calculating volume of cube, box,sphere.
6 Program to test book and tape classes bycreating instances of asking the user to fill intheir data with getdata(),and then displayingthe data with putdata().
7 Program to create text file and thenreading the created text file.
8 Menu driven program for creating, separating,displaying a text file.
9 Menu driven program to add, display andsearch a particular record.
10 Program to input employee details andoperate operation on it through classfunction.
7/31/2019 c++new
3/17
Index
S.NO PROGRAM REMARK
11 Program to do search operation on array ofmembers.
12 Program do operation like insert ,delete ,display element from array .
13 Program do sorting(bubble , insertion, selection)of an array .
14 Program to input two array and do mergingoperation on it .
15 Program to show linked_list .
16 Program to show array_stack and do stack
operation on the array .17 Program to show linked_stack and
do linked_stack operation on it .18 Program to show array_queue and
do array_queue operation on it .
19 Program to show linked_queue anddo linked_queue operation on it.
20 Program to show circular_array_queue and docircular_array_queue operation on it.
21 SQL Commands.
22 SQL Commands for the statements given.
23 SQL Commands for the statements given.
7/31/2019 c++new
4/17
ANSWER:20
//PROGRAM ON CIRCULAR QUEUE
#include#include#includeint max=10;class cqueue{int ar[10];
int front,rear;public:cqueue(){front=-1;rear=-1;}
void insertq(int);void deleteq();void displayq();};void cqueue:: insertq(int item){if((front==0&&rear==max-1)||(front==rear+1))cout
7/31/2019 c++new
5/17
if(f==rear) f=rear=-1;else if(f==max-1)f=0;else f++; }cout
7/31/2019 c++new
6/17
case 2: c1.deleteq();cout
7/31/2019 c++new
7/17
OUTPUT:-
ANSWER:11
// PROGRAM TO SEARCH IN ARRAY
#include#include#include
class array_search{int A[100];int n;public:array_search(){n=0;}void input();
7/31/2019 c++new
8/17
void linearsearch(int k);
OUTPUT:-
7/31/2019 c++new
9/17
7/31/2019 c++new
10/17
+-----------------------------------------------------------+---------+| Number of employees whose name starts from character "s" | 2| || |+-----------------------------------------------------------+---------+1 row in set (0.02 sec)
E) Display max. salary for clerks.
mysql> SELECT DESIGNATION ,MAX(SALARY) FROM DESIG WHEREDESIGNATION='CLERK'GROUP BY DESIGNATION;Empty set (0.01 sec)
ANSWER 22:
A) To display details of those Faculties whose date of joining is
before 31-12-2001.
mysql> SELECT * FROM FACULTY WHERE (YEAR(Hire_date) SELECT * FROM COURSES;+------+------+-------------------+-------+
7/31/2019 c++new
11/17
| C_ID | F_ID | Cname | Fees |+------+------+-------------------+-------+| C21 | 102 | Grid Computing | 40000 || C22 | 103 | System Design | 16500 || C23 | 104 | Computer Security | 8000 |+------+------+-------------------+-------+
D) To display F_ID, Fname, Cname of those faculties whocharged more than15000 as fees.mysql> SELECT A.F_ID ,Fname,Cname FROM FACULTY A,COURSES B WHERE(A.F_ID=B.F_ID) AND Fees >15000;+------+-------+----------------+| F_ID | Fname | Cname |+------+-------+----------------+| 102 | Amit | Grid Computing || 103 | Nitin | System Design |+------+-------+----------------+
E) Display different coursesname from courses.
.mysql> SELECT DISTINCT(Cname) FROM COURSES ;+-------------------+| Cname |+-------------------+| Grid Computing || System Design || Computer Security |+-------------------+
7/31/2019 c++new
12/17
ANSWER 23:
mysql> SELECT * FROM ITEM;+------+-------------------+--------------+-------+| I_ID | ItemName | Manufacturer | Price |+------+-------------------+--------------+-------+| PC06 | Personal Computer | ABC | 35000 |
| LC05 | Laptop | ABC | 55000 || PC03 | Personal Computer | XYZ | 32000 |+------+-------------------+--------------+-------+mysql> SELECT * FROM CUSTOMER;+------+--------------+--------+------+| C_ID | CustomerName | City | I_ID |+------+--------------+--------+------+| 1 | N Roy | Delhi | LC05 || 6 | H Singh | Mumbai | PC03 || 12 | R Pandey | Delhi | PC06 |+------+--------------+--------+------+
A)To display the details of those Customers whose City is Delhi.
mysql> SELECT * FROM CUSTOMER WHERE City ='Delhi';+------+--------------+-------+------+| C_ID | CustomerName | City | I_ID |+------+--------------+-------+------+| 1 | N Roy | Delhi | LC05 || 12 | R Pandey | Delhi | PC06 |+------+--------------+-------+------+
7/31/2019 c++new
13/17
B)To display the details of Items whose Price is in the range of35000 to 55000 (Bothvalues included).
mysql> SELECT * FROM ITEM WHERE Price BETWEEN 35000 AND 55000;+------+-------------------+--------------+-------+| I_ID | ItemName | Manufacturer | Price |+------+-------------------+--------------+-------+| PC06 | Personal Computer | ABC | 35000 || LC05 | Laptop | ABC | 55000 |+------+-------------------+--------------+-------+
C)To display the customer i_id, customer name, city, item name,price.mysql> SELECT A.I_ID,CustomerName,City,ItemName,Price FROM ITEM A,CUSTOMER BWHERE A.I_ID=B.I_ID;+------+--------------+--------+-------------------+-------+| I_ID | CustomerName | City | ItemName | Price |+------+--------------+--------+-------------------+-------+| LC05 | N Roy | Delhi | Laptop | 55000 || PC03 | H Singh | Mumbai | Personal Computer | 32000 || PC06 | R Pandey | Delhi | Personal Computer | 35000 |+------+--------------+--------+-------------------+-------+
D) To increase the Price of all Items by 1000 in the table Item.
mysql> UPDATE ITEM SET Price=Price+1000;Query OK, 3 rows affected (0.01 sec)Rows matched: 3 Changed: 3 Warnings: 0mysql> SELECT * FROM ITEM;+------+-------------------+--------------+-------+| I_ID | ItemName | Manufacturer | Price |
+------+-------------------+--------------+-------+| PC06 | Personal Computer | ABC | 36000 || LC05 | Laptop | ABC | 56000 || PC03 | Personal Computer | XYZ | 33000 |+------+-------------------+--------------+-------+
E) Display no. of cities from table customer.mysql> SELECT COUNT(DISTINCT City) FROM CUSTOMER;+----------------------+| COUNT(DISTINCT City) |+----------------------+| 2 |+----------------------+
7/31/2019 c++new
14/17
ANSWER 24:
mysql> SELECT * FROM SUPPLIER;+---------+---------+-----------+--------+-------------+------+| Numbers | Name | City | Itemno | SuppliedQty | Rate |+---------+---------+-----------+--------+-------------+------+| S001 | Puneet | Delhi | 1008 | 100 | 40 || S002 | Pradeep | Bangalore | 1009 | 200 | 30 |
| S003 | Tanmay | Delhi | 1008 | 150 | 40 || S004 | Rohini | Bombay | 1005 | 190 | 20 || S005 | Tanya | Bombay | 1003 | 20 | 50 || S006 | Aditi | Madras | 1008 | 180 | 40 || S007 | Kush | Delhi | 1009 | 300 | 30 |+---------+---------+-----------+--------+-------------+------+
A) Display names of suppliers whose names start with the letterT.
mysql> SELECT Name FROM SUPPLIER WHERE Name LIKE "T%" ;+--------+
7/31/2019 c++new
15/17
| Name |+--------+| Tanmay || Tanya |+--------+
B) Display details of suppliers residing in Delhi.mysql> SELECT * FROM SUPPLIER WHERE City='Delhi';+---------+--------+-------+--------+-------------+------+
| Numbers | Name | City | Itemno | SuppliedQty | Rate |+---------+--------+-------+--------+-------------+------+| S001 | Puneet | Delhi | 1008 | 100 | 40 || S003 | Tanmay | Delhi | 1008 | 150 | 40 || S007 | Kush | Delhi | 1009 | 300 | 30 |+---------+--------+-------+--------+-------------+------+
C) Display supplier name, item numbers, and supplied quantityfor quantity > 150.
mysql> SELECT Name,Numbers,SuppliedQty FROM SUPPLIERWHERE SuppliedQty>150;+---------+---------+-------------+| Name | Numbers | SuppliedQty |+---------+---------+-------------+| Pradeep | S002 | 200 || Rohini | S004 | 190 || Aditi | S006 | 180 || Kush | S007 | 300 |+---------+---------+-------------+
D) Create a view with one of the columns as rate * 10.
mysql> CREATE VIEW Rate AS SELECT Rate * 10 FROM SUPPLIER;Query OK, 0 rows affected (0.03 sec)mysql> SELECT * FROM Rate;
+-----------+| Rate * 10 |+-----------+| 400 || 300 || 400 || 200 || 500 || 400 || 300 |+-----------+
E) List the suppliers name in the descending order of suppliedquantity.
mysql> SELECT Name FROM SUPPLIER ORDER BY SuppliedQty DESC;
7/31/2019 c++new
16/17
+---------+| Name |+---------+| Kush || Pradeep || Rohini || Aditi || Tanmay || Puneet || Tanya |+---------+
F) List the different cities contained in supplier table.
mysql> SELECT DISTINCT (City) FROM SUPPLIER;+-----------+| City |+-----------+| Delhi || Bangalore || Bombay || Madras |
+-----------+
G).i) SELECT MIN(Rate) FROM SUPPLIER
mysql> SELECT MIN(Rate) FROM SUPPLIER;+-----------+
| MIN(Rate) |+-----------+| 20 |+-----------+
ii) SELECT COUNT(DISTINCT City) FROM SUPPLIER
mysql> SELECT COUNT(DISTINCT City) FROM SUPPLIER;+----------------------+| COUNT(DISTINCT City) |
+----------------------+| 4 |+----------------------+
iii) SELECT Name, Itemno FROM SUPPLIER WHERESuppliedQty>150
mysql> SELECT Name,Itemno FROM SUPPLIER WHERE SuppliedQty>150;+---------+--------+| Name | Itemno |+---------+--------+| Pradeep | 1009 |
7/31/2019 c++new
17/17
| Rohini | 1005 || Aditi | 1008 || Kush | 1009 |+---------+--------+
iv) SELECT (Rate*SuppliedQty) FROM SUPPLIER WHERESuppliedQty>200
mysql> SELECT (RATE*SuppliedQty) FROM SUPPLIER WHERE SuppliedQty>200;+--------------------+| (RATE*SuppliedQty) |+--------------------+| 9000 |+--------------------+