You are on page 1of 18

Title

Page No.

Program 20

Page 62

Program 21

Page 64

Program 22

Page 67

Program 23

Page 70

Program 24

Page 73

Submitted ByAyushman Tripathi


Roll No. : 21
Class : XII-I

/*
Program : 20
Developed By: Ayushman Tripathi
Roll No. : 21
Date
: 09-December-2013
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
const int Max=10;
void Push(int S[], int &T)
{
if (T<Max-1)
{
cout<<"Data:";
cin>>S[++T];
}
else
cout<<"Stack is Full"<<endl;
}

void Pop(int S[], int &T)


{
if (T!=-1)
{
cout<<S[T--]<<"Deleted!"<<endl;
}
else
cout<<"Stack is Empty!"<<endl;
}

void StackDisp(int S[], int T)


{
for (int I=T;I>=0;I--)
cout<<S[I]<<endl;
}

void main()
{
clrscr();
int Stack[Max],Top=-1;
int Ch;

do
{
cout<<"1:Push / 2:Pop / 3:Show / 4:Quit ";
cin>>Ch;
switch(Ch)
{
case 1:Push(Stack,Top);break;
case 2:Pop(Stack,Top);break;
case 3:StackDisp(Stack,Top);break;
}
}
while(Ch!=4);
getch();
}
/*
OUTPUT:
1:Push / 2:Pop / 3:Show / 4:Quit
Data:1
1:Push / 2:Pop / 3:Show / 4:Quit
Data:2
1:Push / 2:Pop / 3:Show / 4:Quit
Data:3
1:Push / 2:Pop / 3:Show / 4:Quit
Data:4
1:Push / 2:Pop / 3:Show / 4:Quit
4
3
2
1
1:Push / 2:Pop / 3:Show / 4:Quit
4Deleted!
1:Push / 2:Pop / 3:Show / 4:Quit
3
2
1
1:Push / 2:Pop / 3:Show / 4:Quit
3Deleted!
1:Push / 2:Pop / 3:Show / 4:Quit
2
1
1:Push / 2:Pop / 3:Show / 4:Quit
*/

1
1
1
1
3

2
3

2
3

/*
Program : 21
Developed By: Ayushman Tripathi
Roll No. : 21
Date
: 9-December-2013
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
struct Student
{
int Admno; char Name[20];
};
const int max=9;
void Qinsert(Student S[], int &R, int F)
{
if ((R+1)%max !=F)
{
R=(R+1)%max;
cout<<"Enter admission no. of the student";
cin>>S[R].Admno;
cout<<"Enter name of the student ";
cin>>S[R].Name;
}
else
cout<<"Queue full\n";
}
void Qdelete(Student S[], int R, int &F)
{
if (R!=F)
{
F=(F+1)%max;
cout<<S[F].Admno<<" "<<S[F].Name<<"..deleted\n";
}
else
cout<<"Queue Empty"<<endl;
}
void Qdisp(Student S[], int R, int F)
{
int Cn=F;
while (Cn!=R)

{
Cn=(Cn+1)%max;
cout<<S[Cn].Admno<<" "<<S[Cn].Name<<endl;
}
}
void main()
{
clrscr();
Student Que[max];
int Rear=0,Front=0;
int Ch;
do
{
cout<<"1:Insert / 2:Delete / 3:Show / 4:Quit ";
cin>>Ch;
switch(Ch)
{
case 1:Qinsert(Que, Rear, Front); break;
case 2:Qdelete(Que, Rear, Front); break;
case 3:Qdisp(Que, Rear, Front); break;
}
}
while(Ch!=4);
getch();
}

/*
OUTPUT:
1:Insert / 2:Delete / 3:Show / 4:Quit
Enter admission no. of the student1
Enter name of the student manav
1:Insert / 2:Delete / 3:Show / 4:Quit
Enter admission no. of the student2
Enter name of the student kunal
1:Insert / 2:Delete / 3:Show / 4:Quit
Enter admission no. of the student3
Enter name of the student ruchi
1:Insert / 2:Delete / 3:Show / 4:Quit
1 manav
2 kunal
3 ruchi
1:Insert / 2:Delete / 3:Show / 4:Quit
1 manav..deleted
1:Insert / 2:Delete / 3:Show / 4:Quit
Enter admission no. of the student4
Enter name of the student anu

2
1

1:Insert / 2:Delete / 3:Show / 4:Quit


2 kunal
3 ruchi
4 anu
1:Insert / 2:Delete / 3:Show / 4:Quit
2 kunal..deleted
1:Insert / 2:Delete / 3:Show / 4:Quit
3 ruchi
4 anu
1:Insert / 2:Delete / 3:Show / 4:Quit
*/

2
3

/*
Program : 22
Developed By: Ayushman Tripathi
Roll No. : 21
Date
: 9-December-2013
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
struct Book
{
int Bno; char Bname[20];
Book *Next;
};
class stack
{
Book *top;
public:
stack(){top=NULL;}
void push(); void pop();
void disp();~stack();
};
void stack::push()
{
Book *temp=new Book;
cout<<"Book no.:";
cin>>temp->Bno;
cout<<"Book name:";
gets(temp->Bname);
temp->Next=top;
top=temp;
}
void stack::pop()
{
if(top!=NULL)
{
Book *temp=top;
cout<<top->Bno<<" "<<top->Bname<<" deleted\n";
top=top->Next; delete temp;
}
else cout<<"Stack Empty\n";

}
void stack::disp()
{
if (top!=NULL)
{
Book *temp=top;
while(temp!=NULL)
{
cout<<temp->Bno<<" "<<temp->Bname<<endl;
temp=temp->Next;
}
}
else cout<<"Stack Empty\n";
}
stack::~stack()
{
while (top!=NULL)
{
Book *temp=top;
top=top->Next;
delete temp;
}
}
void main()
{
clrscr();
stack S; int ch;
do
{
cout<<"1:Push / 2:Pop / 3:Show / 4:Quit ";
cin>>ch;
switch(ch)
{
case 1:S.push();break;
case 2:S.pop();break;
case 3:S.disp();break;
}
}while(ch!=4);
getch();
}
/*
OUTPUT:
1:Push / 2:Pop / 3:Show / 4:Quit 1
Book no.:1

Book name:Harry Potter


1:Push / 2:Pop / 3:Show / 4:Quit
Book no.:2
Book name:Flamingo
1:Push / 2:Pop / 3:Show / 4:Quit
Book no.:3
Book name:Vistas
1:Push / 2:Pop / 3:Show / 4:Quit
3 Vistas
2 Flamingo
1 Harry Potter
1:Push / 2:Pop / 3:Show / 4:Quit
3 Vistas deleted
1:Push / 2:Pop / 3:Show / 4:Quit
2 Flamingo
1 Harry Potter
1:Push / 2:Pop / 3:Show / 4:Quit
*/

2
3

/*
Program : 23
Developed By: Ayushman Tripathi
Roll No. : 21
Date
: 9-December-2013
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
struct NODE
{
int Data; NODE *Next;
};
class Queue
{
NODE *Rear, *Front;
public:
Queue(){Rear=NULL;Front=NULL;}
void Qinsert();
void Qdelete();
void Qdisplay();
~Queue();
};
void Queue::Qinsert()
{
NODE *Temp;
Temp=new NODE;
cout<<"Data:";
cin>>Temp->Data;
Temp->Next=NULL;
if (Rear==NULL)
{
Rear=Temp;
Front=Temp;
}
else
{
Rear->Next=Temp;
Rear=Temp;
}
}

void Queue::Qdelete()
{
if (Front!=NULL)
{
NODE *Temp=Front;
cout<<Front->Data<<" "<<"Deleted\n";
Front=Front->Next;
delete Temp;
if (Front==NULL) Rear=NULL;
}
else
cout<<"Queue Empty..";
}
void Queue::Qdisplay()
{
NODE *Temp=Front;
while(Temp!=NULL)
{
cout<<Temp->Data<<endl;
Temp=Temp->Next;
}
}
Queue::~Queue()
{
while (Front!=NULL)
{
NODE *Temp=Front;
Front=Front->Next; delete Temp;
}
}
void main()
{
clrscr();
Queue QU; int Ch;
do
{
cout<<"1:Push / 2:Pop / 3:Show / 4:Quit ";
cin>>Ch;
switch(Ch)
{
case 1:QU.Qinsert();break;
case 2:QU.Qdelete();break;
case 3:QU.Qdisplay();break;
}

}while(Ch!=4);
getch();
}
/*
OUTPUT:
1:Push / 2:Pop /
Data:1
1:Push / 2:Pop /
Data:2
1:Push / 2:Pop /
Data:3
1:Push / 2:Pop /
Data:4
1:Push / 2:Pop /
1
2
3
4
1:Push / 2:Pop /
1 Deleted
1:Push / 2:Pop /
2
3
4
1:Push / 2:Pop /
2 Deleted
1:Push / 2:Pop /
3
4
1:Push / 2:Pop /
*/

3:Show / 4:Quit 1
3:Show / 4:Quit 1
3:Show / 4:Quit 1
3:Show / 4:Quit 1
3:Show / 4:Quit 3

3:Show / 4:Quit 2
3:Show / 4:Quit 3

3:Show / 4:Quit 2
3:Show / 4:Quit 3

3:Show / 4:Quit 4

/*
Program : 24
Developed By: Ayushman Tripathi
Roll No. : 21
Date
: 9-December-2013
*/
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.30-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database d;
Query OK, 1 row affected (0.00 sec)
mysql> use d;
Database changed
mysql> insert into teacher values(202, 'kriti khaneja', 'humanities', 28000, '19
78-12-12');
Query OK, 1 row affected (0.02 sec)
mysql> insert into teacher values(103, 'adil mehra', 'science', 8000, '2001-02-1
4');
Query OK, 1 row affected (0.02 sec)
mysql> insert into teacher values(305, 'nishiya goel', 'commerce', 12000, '198503-19');
Query OK, 1 row affected (0.02 sec)
mysql> insert into teacher values(203, 'shubh pandit', 'humanities', 22000, '198
5-03-19');
Query OK, 1 row affected (0.03 sec)
mysql> insert into teacher values(109, 'naina', 'science', 20000, '1994-07-17");
mysql> create table stud ( scode decimal(2), name varchar(20), tcode decimal(3),
agg decimal(2));
Query OK, 0 rows affected (0.05 sec)
mysql> insert into stud values(2, 'nabi ahmed', 101, 91);
Query OK, 1 row affected (0.05 sec)
mysql> insert into stud values (1, 'ravi sahal', 305, 84);
Query OK, 1 row affected (0.01 sec)

mysql> insert into stud values (5, 'vibhuti', 203, 67);


Query OK, 1 row affected (0.01 sec)
mysql> insert into stud values(4, 'nazeem', 103, 89);
Query OK, 1 row affected (0.02 sec)
mysql> insert into stud values(3, 'aryana', 202, 37);
Query OK, 1 row affected (0.01 sec)
mysql> insert into stud values(6, 'johnathon', 305, 45);
Query OK, 1 row affected (0.02 sec)
mysql> select * from teacher;
+-------+---------------+------------+-------+------------+
| tcode | tname
| stream
| basic | doj
|
+-------+---------------+------------+-------+------------+
|
101 | ananya murti | science
| 1800 | 1990-01-23 |
|
202 | kriti khaneja | humanities | 28000 | 1978-12-12 |
|
103 | adil mehra
| science
| 8000 | 2001-02-14 |
|
305 | nishiya goel | commerce
| 12000 | 1997-01-01 |
|
203 | shubh pandit | humanities | 22000 | 1985-03-19 |
|
109 | naina
| science
| 20000 | 1994-07-17 |
+-------+---------------+------------+-------+------------+
6 rows in set (0.03 sec)
mysql> select * from teacher where doj>='1978-01-01' and doj<='1992-11-30';
+-------+---------------+------------+-------+------------+
| tcode | tname
| stream
| basic | doj
|
+-------+---------------+------------+-------+------------+
|
101 | ananya murti | science
| 1800 | 1990-01-23 |
|
202 | kriti khaneja | humanities | 28000 | 1978-12-12 |
|
203 | shubh pandit | humanities | 22000 | 1985-03-19 |
+-------+---------------+------------+-------+------------+
3 rows in set (0.02 sec)
mysql> select name, scode from stud order by agg desc;
+------------+-------+
| name
| scode |
+------------+-------+
| nabi ahmed |
2 |
| nazeem
|
4 |
| ravi sahal |
1 |
| vibhuti
|
5 |
| johnathon |
6 |
| aryana
|
3 |
+------------+-------+
6 rows in set (0.01 sec)
mysql> select name, scode from stud where tcode=103 or tcode=203 ;
+---------+-------+
| name
| scode |
+---------+-------+
| vibhuti |
5 |
| nazeem |
4 |
+---------+-------+

2 rows in set (0.00 sec)


mysql> select tname, basic*(25/100) as "income tax" from teacher;
+---------------+------------+
| tname
| income tax |
+---------------+------------+
| ananya murti |
450.0000 |
| kriti khaneja | 7000.0000 |
| adil mehra
| 2000.0000 |
| nishiya goel | 3000.0000 |
| shubh pandit | 5500.0000 |
| naina
| 5000.0000 |
+---------------+------------+
6 rows in set (0.00 sec)
mysql> update stud set agg=82 where name= 'ravi sahal';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update teacher set stream='humanities', tcode=210 where tname ='ananya mu
rti';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> alter table stud add(grade varchar(1));
Query OK, 6 rows affected (0.16 sec)
Records: 6 Duplicates: 0 Warnings: 0
mysql> update stud set grade='A' where agg>=70;
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> update stud set grade='B' where agg>=40 and agg<=70;
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> update stud set grade='C' where agg<=40;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select tcode, tname from teacher where stream='humanities' order by tcode
;
+-------+---------------+
| tcode | tname
|
+-------+---------------+
|
202 | kriti khaneja |
|
203 | shubh pandit |
|
210 | ananya murti |
+-------+---------------+
3 rows in set (0.00 sec)

mysql> select tname, stream, doj from teacher order by stream, doj desc;
+---------------+------------+------------+
| tname
| stream
| doj
|
+---------------+------------+------------+
| nishiya goel | commerce
| 1997-01-01 |
| ananya murti | humanities | 1990-01-23 |
| shubh pandit | humanities | 1985-03-19 |
| kriti khaneja | humanities | 1978-12-12 |
| adil mehra
| science
| 2001-02-14 |
| naina
| science
| 1994-07-17 |
+---------------+------------+------------+
6 rows in set (0.00 sec)
mysql> select tname, max(basic), stream from teacher group by stream;
+--------------+------------+------------+
| tname
| max(basic) | stream
|
+--------------+------------+------------+
| nishiya goel |
12000 | commerce
|
| ananya murti |
28000 | humanities |
| adil mehra
|
20000 | science
|
+--------------+------------+------------+
3 rows in set (0.00 sec)
mysql> select sum(basic), avg(basic) from teacher;
+------------+------------+
| sum(basic) | avg(basic) |
+------------+------------+
|
91800 | 15300.0000 |
+------------+------------+
1 row in set (0.00 sec)
mysql> select name, tcode, min(agg) from stud where tcode>=200;
+------------+-------+----------+
| name
| tcode | min(agg) |
+------------+-------+----------+
| ravi sahal |
305 |
37 |
+------------+-------+----------+
1 row in set (0.00 sec)
mysql> select count(distinct stream)from teacher;
+------------------------+
| count(distinct stream) |
+------------------------+
|
3 |
+------------------------+
1 row in set (0.00 sec)
mysql> select count(*) from teacher;
+----------+
| count(*) |
+----------+
|
6 |
+----------+

1 row in set (0.00 sec)


mysql> update teacher set basic=(basic+10000) where doj<='1995-02-01';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> select s.name, t.tname from stud s, teacher t where s.tcode=t.tcode;
+------------+---------------+
| name
| tname
|
+------------+---------------+
| aryana
| kriti khaneja |
| nazeem
| adil mehra
|
| ravi sahal | nishiya goel |
| johnathon | nishiya goel |
| vibhuti
| shubh pandit |
+------------+---------------+
5 rows in set (0.00 sec)
mysql> select count(*), stream from teacher group by stream;
+----------+------------+
| count(*) | stream
|
+----------+------------+
|
1 | commerce
|
|
3 | humanities |
|
2 | science
|
+----------+------------+
3 rows in set (0.00 sec)
mysql> select distinct stream from teacher;
+------------+
| stream
|
+------------+
| humanities |
| science
|
| commerce
|
+------------+
3 rows in set (0.00 sec)
mysql> select min(basic), stream from teacher group by stream having count(*)>=2
;
+------------+------------+
| min(basic) | stream
|
+------------+------------+
|
11800 | humanities |
|
8000 | science
|
+------------+------------+
2 rows in set (0.00 sec)
mysql> delete from stud where agg<40;
Query OK, 1 row affected (0.02 sec)

mysql> select * from stud;


+-------+------------+-------+------+-------+
| scode | name
| tcode | agg | grade |
+-------+------------+-------+------+-------+
|
2 | nabi ahmed |
101 |
91 | A
|
|
1 | ravi sahal |
305 |
82 | A
|
|
5 | vibhuti
|
203 |
67 | B
|
|
4 | nazeem
|
103 |
89 | A
|
|
6 | johnathon |
305 |
45 | B
|
+-------+------------+-------+------+-------+
5 rows in set (0.00 sec)

You might also like