Professional Documents
Culture Documents
Page No.
Program 20
Page 62
Program 21
Page 64
Program 22
Page 67
Program 23
Page 70
Program 24
Page 73
/*
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 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
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
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> 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 |
+----------+