0% found this document useful (0 votes)
55 views

C++ Assignment::-Vivek Chauhan: - XII-A

This document contains the details of 20 C++ programs assigned to a student named Vivek Chauhan studying in class 12A. It includes the program name, program description and remarks for each program assignment. The programs cover concepts like classes, arrays, stacks, queues, linked lists, file handling and SQL commands.

Uploaded by

Vivek Chauhan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

C++ Assignment::-Vivek Chauhan: - XII-A

This document contains the details of 20 C++ programs assigned to a student named Vivek Chauhan studying in class 12A. It includes the program name, program description and remarks for each program assignment. The programs cover concepts like classes, arrays, stacks, queues, linked lists, file handling and SQL commands.

Uploaded by

Vivek Chauhan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

C++ Assignment

:VIVEK CHAUHAN
:- XII-A

Index
S.NO
1
2
3
4
5
6

PROGRAM

Program to add distance type object into third


one.
Program to define employee class in c++.
Program to represent batsmen in a cricket
team.
Program to create the student pass fail data.
Program for calculating volume of cube, box,
sphere.
Program to test book and tape classes by
creating instances of asking the user to fill in
their data with getdata(),and then displaying
the data with putdata().

Program to create text file and then


reading the created text file.

Menu driven program for creating, separating,


displaying a text file.

Menu driven program to add, display and


search a particular record.
Program to input employee details and
operate operation on it through class
function.

10

REMARK

Index
S.NO

PROGRAM

11

Program to do search operation on array of


members.

12

Program do operation like insert ,delete ,


display element from array .
Program do sorting(bubble , insertion, selection)
of an array .
Program to input two array and do merging
operation on it .
Program to show linked_list .

13
14
15
16
17
18

Program to show array_stack and do stack


operation on the array .
Program to show linked_stack and
do linked_stack operation on it .
Program to show array_queue and
do array_queue operation on it .

19

Program to show linked_queue and


do linked_queue operation on it.

20
21

Program to show circular_array_queue and do


circular_array_queue operation on it.
SQL Commands.

22

SQL Commands for the statements given.

23

SQL Commands for the statements given.

REMARK

ANSWER:20
//PROGRAM ON CIRCULAR QUEUE
#include<iostream.h>
#include<conio.h>
#include<process.h>
int 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<<"\nOVERFLOW.....";
else
if (rear==-1)
front=rear=0;
else
if(rear==max-1)
rear=0;
else
rear++;
ar[rear]=item;
}
void cqueue::deleteq(){
int temp,f;
f=front;
if(f==-1)
cout<<"EMPTY QUEUE ...";
else{
temp=ar[f];

if(f==rear) f=rear=-1;
else if(f==max-1)
f=0;
else f++; }
cout<<"ELEMENT DELETED:"<<temp;
}
void cqueue:: displayq(){
int i=0;
cout<<"QUEUE IS AS:(front(>>>),rear(<<<) & free space -)\n";
if (front==-1)
cout<<"QUEUE EMPTY...";
else if(rear>=front)
{
for(i=0;i<front;i++)
cout<<"-";
cout<<">>>";
for(i=0;i<rear;i++)
cout<<ar[i]<<"<-";
cout<<ar[rear]<<"<<<"<<endl;
} else
{ for(i=0;i<rear;i++) cout<<ar[i]<<"<-";
cout<<ar[rear]<<"<<<";
for(;i<front;i++)
cout<<"-";
cout<<">>>";
for(i=front;i<max;i++) cout<<ar[i]<<"<-";
cout<<"\t...wrap around..";}
}
void main(){
clrscr();
cqueue c1;
int item,ch;
do{
cout<<"\n\t\tCIRCULAR QUEUE MENU\n";
cout<<"\n[1]TO INSERT AN ELEMENT";
cout<<"\n[2]TO DELETE AN ELEMENT FROM QUEUE";
cout<<"\n[3]TO DISPLAY AN ELEMENT WITHOUT DELETION";
cout<<"\n[4]QUIT";
cout<<"\nENTER THE CHOICE(1-4):";
cin>>ch;
switch(ch){
case 1: char ch1='y';
while(ch1=='y'||ch1=='Y'){
cout<<"\nENTER THE ITEM FOR INSERTION:";
cin>>item;
c1.insertq(item);
cout<<"\nWANT TO INSERT MORE ELEMENTS(Y/N):";
cin>>ch1;
} break;

case 2: c1.deleteq();
cout<<"\nDELETION SUCCEDED..";
getch(); break;
case 3: c1.displayq(); getch(); break;
case 4: exit(0); }
}while(ch!=4); }

OUTPUT:-

OUTPUT:-

ANSWER:11
// PROGRAM TO SEARCH IN ARRAY

#include<iostream.h>
#include<conio.h>
#include<process.h>
class array_search
{int A[100];
int n;
public:
array_search()
{n=0;}
void input();

void linearsearch(int k);

OUTPUT:-

Answer 21:
A). Display FirstName and City of Employee having salary
between 50,000 and 90,000.

mysql> SELECT FIRSTNAME,CITY FROM EMPLOYEE,DESIG WHERE (SALARY BETWEEN


50000 AND
90000) AND EMPLOYEE.W_ID=DESIG.W_ID;
+-----------+-----------+
| FIRSTNAME | CITY
|
+-----------+-----------+
| SAM
| PARIS
|
| SARAH
| NEW YORK |
| MANILA | NEW DELHI |
+-----------+-----------+
3 rows in set (0.00 sec)

B) Display details of Employees who are from PARIS city.


mysql>SELECT
EMPLOYEE.W_ID,FIRSTNAME,LASTNAME,CITY,SALARY,BENEFIT,DESIGNATION
FROM EMPLOYEE ,DESIG WHERE CITY='PARIS'AND EMPLOYEE.W_ID=DESIG.W_ID;
+------+-----------+----------+-------+--------+---------+------------+
| W_ID | FIRSTNAME | LASTNAME | CITY | SALARY | BENEFIT | DESIGNATION|
|
|
|
|
|
|
|
|
+------+-----------+----------+-------+--------+---------+------------+
| 102 | SAM
| TONES | PARIS | 75000 | 15000 | MANAGER |
|
|
|
|
|
|
|
+------+-----------+----------+-------+--------+---------+------------+
1 row in set (0.00 sec)

C) Increase the benefits of employee having W_ID = 210 by 500.


mysql> UPDATE DESIG SET BENEFIT=BENEFIT+500 WHERE W_ID=210;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

D) Count number of employees whose name starts from


character S.
mysql> SELECT 'Number of employees whose name starts from character "s" ',COUNT(
*) FROM EMPLOYEE WHERE FIRSTNAME LIKE 'S%';
+-----------------------------------------------------------+---------+
| Number of employees whose name starts from character "s" | COUNT(*)| |
|
|

+-----------------------------------------------------------+---------+
| Number of employees whose name starts from character "s" |
|
|
+-----------------------------------------------------------+---------+
1 row in set (0.02 sec)

2| |

E) Display max. salary for clerks.


mysql> SELECT DESIGNATION ,MAX(SALARY) FROM DESIG WHERE
DESIGNATION='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)<2001) OR
(DAY(Hire_date)<31 AND MONTH(Hire_date)=2001) OR (MONTH(Hire_date)<12 AND
YEAR(Hire_date)=2001);
+------+---------+--------+------------+--------+
| F_ID | Fname | Lname | Hire_date | Salary |
+------+---------+--------+------------+--------+
| 102 | Amit | Mishra | 1998-10-12 | 12000 |
| 103 | Nitin | Vyas | 1994-12-24 | 8000 |
| 104 | Rakshit | Soni | 2001-05-18 | 14000 |
+------+---------+--------+------------+--------+
3 rows in set (0.02 sec)

B) To display the details of courses whose fees is in the range of


15000 to 50000 (both values included).
mysql> SELECT * FROM COURSES WHERE Fees BETWEEN 15000 AND 50000;
+------+------+----------------+-------+
| C_ID | F_ID | Cname
| Fees |
+------+------+----------------+-------+
| C21 | 102 | Grid Computing | 40000 |
| C22 | 103 | System Design | 16000 |
+------+------+----------------+-------+

C) To increase the fees of System Design course by 500.


mysql> UPDATE COURSES SET Fees=Fees + 500
Design';Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM COURSES;
+------+------+-------------------+-------+

WHERE Cname='System

| 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 who


charged 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 |
+-------------------+

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 |
+------+--------------+-------+------+

B)To display the details of Items whose Price is in the range of


35000 to 55000 (Both values 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 B


WHERE 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: 0
mysql> 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|
+----------------------+

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 letter


T.
mysql> SELECT Name FROM SUPPLIER WHERE Name LIKE "T%" ;
+--------+

| 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 quantity


for quantity > 150.
mysql> SELECT Name,Numbers,SuppliedQty FROM SUPPLIER
WHERE 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 supplied


quantity.
mysql> SELECT Name FROM SUPPLIER ORDER BY SuppliedQty DESC;

+---------+
| 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 WHERE


SuppliedQty>150
mysql> SELECT Name,Itemno FROM SUPPLIER WHERE SuppliedQty>150;
+---------+--------+
| Name | Itemno |
+---------+--------+
| Pradeep | 1009 |

| Rohini | 1005 |
| Aditi | 1008 |
| Kush | 1009 |
+---------+--------+

iv) SELECT (Rate*SuppliedQty) FROM SUPPLIER WHERE


SuppliedQty>200
mysql> SELECT (RATE*SuppliedQty) FROM SUPPLIER WHERE SuppliedQty>200;
+--------------------+
| (RATE*SuppliedQty) |
+--------------------+
|
9000 |
+--------------------+

You might also like