C++ Assignment::-Vivek Chauhan: - XII-A
C++ Assignment::-Vivek Chauhan: - XII-A
:VIVEK CHAUHAN
:- XII-A
Index
S.NO
1
2
3
4
5
6
PROGRAM
10
REMARK
Index
S.NO
PROGRAM
11
12
13
14
15
16
17
18
19
20
21
22
23
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();
OUTPUT:-
Answer 21:
A). Display FirstName and City of Employee having salary
between 50,000 and 90,000.
+-----------------------------------------------------------+---------+
| Number of employees whose name starts from character "s" |
|
|
+-----------------------------------------------------------+---------+
1 row in set (0.02 sec)
2| |
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)
WHERE Cname='System
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 |
+------+--------------+--------+------+
C)To display the customer i_id, customer name, city, item name,
price.
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 |
+---------+---------+-----------+--------+-------------+------+
| Name |
+--------+
| Tanmay |
| Tanya |
+--------+
+---------+
| Name |
+---------+
| Kush |
| Pradeep |
| Rohini |
| Aditi |
| Tanmay |
| Puneet |
| Tanya |
+---------+
G).
i) SELECT MIN(Rate) FROM SUPPLIER
mysql> SELECT MIN(Rate) FROM SUPPLIER;
+-----------+
| MIN(Rate) |
+-----------+
|
20 |
+-----------+
| Rohini | 1005 |
| Aditi | 1008 |
| Kush | 1009 |
+---------+--------+