Computer
Computer
S.NO
TOPIC
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
SQL COMM@NDS
switch(k)
{
case 1: ch='y';
while(ch=='y'||ch=='Y')
{ cout<<"\nEnter the element : ";
cin>>item;
res=push(stack,top,item);
if(res==-1)
{cout<<"\nOverflow !!!!";
exit(1); }
cout<<"\nThe stack formed is : \n\n";
display(stack,top);
cout<<"\n\n\nWant to enter again ?: ";
cin>>ch;
}
break;
case 2: ch='y';
while(ch=='y'||ch=='Y')
{ res=pop(stack,top);
if(res==-1)
{
cout<<"\nUnderflow !!!!";
exit(1);
}
else
{
cout<<"\nThe deleted Element is : "<<res<<endl;
case 4: exit(0);
break;
// end of switch
}while(m=='y'||m=='Y');
getch();
}
// end of main()
if(top==size-1)
return -1;
else
{
top++;
stack[top]=el;
return 0;
}
}
cout<<sttack[top]<<"<--";
ffor(int i=ttop-1;i>=0;i--)
ccout<<staack[i]<<"<--";
}
O
Outputt
#include<iostream.h>
#include<conio.h>
#include<process.h>
const int size=50;
int q[size],rear=-1,front=-1;
int insert(int q[],int ele)
{
if(rear==size-1)
return(-1);
else if(rear==-1)
{
front=rear=0;
q[rear]=ele;
}
else
{
rear++;
q[rear]=ele;
}
return(0);
}
int delet(int q[])
{
int r ;
if(front==-1)
return(-1);
else
{
r=q[front];
if(rear==front)
front=rear=-1;
else
front++;
}
return r;
}
void display(int q[],int front,int rear)
{
if(front==-1)
return;
else
{
for(int i=front;i<=rear;i++)
cout<<q[i]<<" ";
}
}
void main()
{
clrscr();
int n,u,k,m;
char ch,ans;
do
{
cout<<"\nChoose from the menu :\n"
<<"\n 1. Insert"
<<"\n 2. Delete"
<<"\n 3. Display"
<<"\n\n Enter your choice : "; cin>>n;
switch(n)
{
case 1: ans='y';
while(ans=='y'||ans=='Y')
{
cout<<"\n Enter element to be inserted :"; cin>>m;
k=insert(q,m);
if(k==-1)
cout<<"\n Overflow !!!!";
cout<<"\n The resultant Queue is : ";
display(q,front,rear);
cout<<"\n\n Want to enter again ?: ";
cin>>ans;
}
break;
case 2: ans='y';
while(ans=='y'||ans=='Y')
{
u=delet(q);
if(u==-1)
{
nderflow !!!!";
cout<<"\n Un
breakk;
}
ellse
{
he deleted
d element is "<<u<<"\n";
cout<<"\n Th
he resultant Queue is : \n\n"";
cout<<"\n Th
displlay(q,front,rear);
}
cout<<"\n\n Waant to deleete again ?: ";
ns;
cin>>an
}
break;
case 3: cout<<"\
\n The Quueue is : \n
n\n";
d
display(q,f
front,rear));
b
break;
default: cout<<"\
\n Please enter desiired keyw
word : ";
}
cout<<"\n Choose from th
he menu aagain ? : ";cin>>ch;
while(ch=
=='y'||ch=
=='Y');
}w
getch());
}
O
OUTPUT
T
{
cout<<np->roll<<" -> ";
np=np->next;
}
}
void main()
{
clrscr();
top=NULL;
int n,m;
char k,ch;
do {
cout<<"\nChoose from the menu :\n"
<<"\n 1. Push."
<<"\n 2. Pop."
<<"\n 3. Display."
<<"\n 4. Quit."
<<"\n\nEnter your choice : ";
cin>>n;
switch(n)
{
case 1: k='y';
while(k=='y'||k=='Y')
{
cout<<"\n Enter element to be inserted .";
cin>>m;
newptr=create(m);
if(newptr==NULL)
cout<<"\n Cannot create !!!!";
push(newptr);
cout<<"\n The Stack formed is : ";
display(top);
cout<<"\n\n Want to enter again ?: ";
cin>>k;
}
break;
case 2: k='y';
while(k=='y'||k=='Y')
{
pop();
med is : \n
n\n";
cout<<"\n The SStack form
display((top);
cout<<"\n\n Waant to deleete again ?: ";
cin>>k;;
}
b
break;
case 3: cout<<"\
\n The Staack formeed is : ";
display(top
d
p);
b
break;
case 4: exit(0);
b
break;
default: cout<<"\
\n Please enter desiired keyw
word : ";
}
ccout<<"\\n Do you want to ccontinue..? : ";
ccin>>ch;
while(ch=
=='y'||ch=
=='Y');
}w
getch();
}
O
Outputt
cout<<"\n Underflow!!!!";
else
{
ptr=front;
front=front->next;
delete ptr;
}
}
void display(node *np)
{
while(np!=NULL)
{
cout<<np->roll<<"-> ";
np=np->next;
}
}
void main()
{
clrscr();
front=rear=NULL;
int n,m;
char ans,ch;
do
{ cout<<"\nChoose from the menu : "
<<"\n 1) Insert."
<<"\n 2) Delete
<<"\n 3) Display."
<<"\n\n Enter your choice : ";
cin>>n;
switch(n)
{
case 1: ans='y';
while(ans=='y'||ans=='Y')
{
cout<<"\n Enter element to be inserted .";
cin>>m;
newptr=create(m);
if(newptr==NULL)
cout<<"\n Cannot create !!!!";
insert(newptr);
cout<<"\n The Queue formed is : ";
display(front);
cout<<"\n Want to enter more nodes ?: ";
cin>>ans;
}
break;
case 2: ans='y';
while(ans=='y'||ans=='Y')
{
delet();
cout<<"\n Queue : ";
display(front);
cout<<"\n Want to delete more ?: ";
cin>>an
ns;
}
b
break;
case 3: cout<<"\
\n Queue : ";
d
display(fro
ont);
b
break;
default: cout<<"\
\n You en
ntered wroong choicee...";
}
ccout<<"\\n Want to return tto main menu
m
? : ";
ccin>>ch;
}w
while(ch=
=='y'||ch=
=='Y');
getch();
}
O
Outputt