SlideShare a Scribd company logo
1. INSERTION AND DELETION
PROGRAM:
#include<stdio.h>
void main()
{
int n,c,a,value,position,array[50];
clrscr();
printf("Enter the number of elements in arrayn");
scanf("%d",&n);
printf("Enter the %d elements n",n);
for(c=0;c<n;c++)
scanf("%d",&array[c]);
printf("1.Insertiont2.Deletionn");
scanf("%d",&a);
if(a==1)
{
printf("Enter the location where you wish to insert elementn");
scanf("%d",&position);
printf("Enter the value to insertn");
scanf("%d",&value);
for(c=n-1;c>=position-1;c--)
array[c+1]=array[c];
array[position-1]=value;
printf("Array is");
for(c=0;c<=n;c++)
printf("%dt",array[c]);
getch();
}
else
{
printf("Enter the location where you wish to delete elementn");
scanf("%d",&position);
if(position>=n+1)
printf("Deletion not posiblen");
for(c=position-1;c<n;c++)
array[c]=array[c+1];
printf("Array after deletion isn");
for(c=0;c<n-1;c++)
printf("%dt",array[c]);
getch();
}
}
OUTPUT:
Enter the number of elements in array
5
Enter the 5 elements
2
4
6
8
10
1.Insertion 2.Deletion
1
Enter the location where you wish to insert element
4
Enter the value to insert
7
Array is 2 4 6 7 8 10
Enter the number of elements in array
5
Enter the 5 elements
2
4
6
8
10
1.Insertion 2.Deletion
2
Enter the location where you wish to delete element
4
Array after deletion is
2 4 6 10
2. MERGING TWO SORTED ARRAYS
PROGRAM:
#include<stdio.h>
voidmain()
{
inta[50],b[50],c[100],m,n,i,j,k=0;
clrscr();
printf("nEntersize of array A:n");
scanf("%d",&m);
printf("nEntersortedelementsof arrayA:n");
for(i=0;i<m;i++)
{
scanf("%d",&a[i]);
}
printf("nEntersize of arrayB:n");
scanf("%d",&n);
printf("nEntersortedelementsof arrayB:n");
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
i=0;
j=0;
while(i<m&&j<n)
{
if(a[i]<b[j])
{
c[k]=a[i];
i++;
}
else
{
c[k]=b[j];
j++;
}
k++;
}
if(i>=m)
{
while(j<n)
{
c[k]=b[j];
j++;
k++;
}
}
if(j>=n)
{
while(i<m)
{
c[k]=a[i];
i++;
k++;
}
}
printf("nAftermerging:n");
for(i=0;i<m+n;i++)
{
printf("n%d",c[i]);
}
getch();
}
OUTPUT:
Enter sorted elements of array A:
2
4
6
8
Enter size of array B:
4
Enter sorted elements of array B:
1
3
5
7
After merging:
1
2
3
4
5
6
7
8
3. SEARCHING AN ELEMENT IN 2-D ARRAY
PROGRAM:
#include<stdio.h>
#include<conio.h>
voidmain()
{
inta[20][20],i,j,m,n,pos,item;
char f;
int*p=&a[0][0];
clrscr();
printf("Enterthe numberof row n");
scanf("%d",&m);
printf("Enterthe numberof column n");
scanf("%d",&n);
printf("Enterthe dataone byone in row wise n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
printf("Enterthe searchitem n");
scanf("%d",&item);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]==item)
{
p=p+(i*n+j)*16;
f='y';
printf("The searchitem%disinposition[%d][%d]",item,i,j);
printf("nTheaddressof the searchitem%dis%u",item,p);
break;
}
}
}
if(f!='y')
printf("nThesearchitem%disnotpresentinthe array",item);
getch();
}
OUTPUT:
Enter the numberof row
4
Enter the numberof column
3
Enter the data one by one inrow wise
2
4
6
8
10
12
14
16
18
20
22
24
Enter the searchitem
12
The search item12 isin position[1][2]
The addressof the searchitem12 is 64876
4. STACK OPERATION USING ARRAY
PROGRAM:
#include<stdio.h>
#include<conio.h>
#define n 10
struct stack
{
int top;
int data[n];
};
void main()
{
struct stack s;
int i,opt,item;
clrscr();
s.top=-1;
do
{
printf("n1.Pushn");
printf("2.Popn");
printf("3.Listn");
printf("4.Exitn");
printf("Enter any one optionn");
scanf("%d",&opt);
switch(opt)
{
case 1:if(s.top==n-1)
printf("Stack Fulln");
else
{
printf("Enter the data to push into the stackn");
scanf("%d",&item);
s.top=s.top+1;
s.data[s.top]=item;
}
break;
case 2:if(s.top==-1)
printf("Stack emptyn");
else
{
printf("The deleted element from stack is %d",s.data[s.top]);
s.top--;
}
break;
case 3:if(s.top==-1)
printf("n stack empty");
else
{
printf("The elements in the stack aren");
for(i=s.top;i>=0;i--)
printf("n%dn",s.data[i]);
}
break;
}
}
while(opt!=4);
getch();
}
OUTPUT:
1.Push
2.Pop
3.List
4.Exit
Enter any one option
1
Enter the data to push into the stack
10
1.Push
2.Pop
3.List
4.Exit
Enter any one option
1
Enter the data to push into the stack
20
1.Push
2.Pop
3.List
4.Exit
Enter any one option
1
Enter the data to push into the stack
30
1.Push
2.Pop
3.List
4.Exit
Enter any one option
3
The elements in the stack are
30
20
10
1.Push
2.Pop
3.List
4.Exit
Enter any one option
2
The deleted element from stack is 30
1.Push
2.Pop
3.List
4.Exit
Enter any one option
2
The deleted element from stack is 30
1.Push
2.Pop
3.List
4.Exit
Enter any one option
3
The elements in the stack are
20
10
1.Push
2.Pop
3.List
4.Exit
Enter any one option
4
5. CONVERTING INFIX EXPRESSION TO POSTFIX EXPRESSION
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct stack
{
intdata[50];
inttop;
};
struct stack s;
char infix[50],post[50];
voidpostfix();
voidpush(int);
char pop();
voidmain()
{
clrscr();
printf("Enterthe infix expressionn");
scanf("%s",infix);
postfix();
getch();
}
voidpostfix()
{
inti,j=0;
for(i=0;infix[i]!='0';i++)
{
switch(infix[i])
{
case'+':
while(s.data[s.top]>=i)
post[j++]=pop();
push(1);
break;
case'-':
while(s.data[s.top]>=1)
post[j++]=pop();
push(2);
break;
case'*':
while(s.data[s.top]>=3)
post[j++]=pop();
push(3);
break;
case'/':
while(s.data[s.top]>=4)
post[j++]=pop();
push(4);
break;
case'^':
while(s.data[s.top]>=4)
post[j++]=pop();
push(5);
break;
case'(':
push(0);
break;
case')':
while(s.data[s.top]!=0)
post[j++]=pop();
s.top--;
break;
default:
post[j++]=infix[i];
}
}
while(s.top>0)
post[j++]=pop();
printf("ntThe postfix expressionis t%s",post);
}
voidpush(intv)
{
s.top++;
s.data[s.top]=v;
}
char pop()
{
inta;
char c;
a=s.data[s.top];
s.top--;
switch(a)
{
case 1:
c='+';
break;
case 2:
c='-';
break;
case 3:
c='*';
break;
case 4:
c='/';
break;
case 5:
c='^';
break;
}
return(c);
}
OUTPUT:
Enter the infix expression
(a+b*c-d/e)
The postfix expressionis abc*+de/-
6. EVALUATING A POSTFIX EXPRESSION
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<ctype.h>
struct stack
{
inttop;
floata[20];
}s;
voidmain()
{
inti,n;
floatopt1,opt2,opt3;
char ex[20];
clrscr();
s.top=-1;
printf("nEnterthe postfix expression:");
gets(ex);
n=strlen(ex);
for (i=0;i<n;i++)
{
if (isdigit(ex[i]))
{
s.top++;
s.a[s.top]=ex[i]-'0';
}
else
{
opt2=s.a[s.top--];
opt1=s.a[s.top--];
switch(ex[i])
{
case'+':
opt3=opt1+opt2;
break;
case'-':
opt3=opt1-opt2;
break;
case'*':
opt3=opt1*opt2;
break;
case'/':
opt3=opt1/opt2;
break;
case'^':
opt3=pow(opt1,opt2);
break;
}
s.a[++s.top]=opt3;
}
}
printf("nTheResult%sis%.2f",ex,s.a[s.top]);
getch();
}
OUTPUT:
Enter the postfix expression:853*+94/-
The Result853*+94/- is20.75
7. QUEUE OPERATIONS USING ARRAY
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct queue
{
intdata[50];
intfront;
intrear;
};
inti,opt,item;
intx;
voidmain()
{
struct queue q;
clrscr();
q.front=-1;
q.rear=-1;
do
{
printf("Selectanyone option n");
printf("1.Create n");
printf("2.Listn");
printf("3.Insert n");
printf("4.Deleten");
printf("5.Exitn");
scanf("%d",&opt);
switch(opt)
{
case 1:
printf("Enter10data one by one n");
for(i=0;i<10;i++)
scanf("%d",&q.data[++q.rear]);
break;
case 2:
printf("The datainthe queue are n");
for(i=q.front+1;i<=q.rear;i++)
printf("%dn",q.data[i]);
break;
case 3:
printf("Enterthe datatoinsert n");
scanf("%d",&item);
q.data[++q.rear]=item;
break;
case 4:
q.front++;
x=q.data[q.front];
printf("nThedeleateditemis t%dn",x);
break;
}
}
while(opt!=5);
getch();
}
OUTPUT:
Selectanyone option
1.Create
2.List
3.Insert
4.Delete
5.Exit
1
Enter 10 data one byone
1
2
3
4
5
6
7
8
9
10
Selectanyone option
1.Create
2.List
3.Insert
4.Delete
5.Exit
3
Enter the data to insert
11
1.Create
2.List
3.Insert
4.Delete
5.Exit
2
The data in the queue are
1
2
3
4
5
6
7
8
9
10
11
Selectanyone option
1.Create
2.List
3.Insert
4.Delete
5.Exit
4
The deleateditemis 1
Selectanyone option
1.Create
2.List
3.Insert
4.Delete
5.Exit
4
The deleateditemis 2
Selectanyone option
1.Create
2.List
3.Insert
4.Delete
5.Exit
5
Data structure output 1

More Related Content

PPTX
Examples sandhiya class'
PPTX
LAB PROGRAMS SARASWATHI RAMALINGAM
DOCX
ADA FILE
PDF
Data Structure in C Programming Language
PDF
Data Structure using C
DOCX
DataStructures notes
PPSX
C programming array & shorting
DOCX
Examples sandhiya class'
LAB PROGRAMS SARASWATHI RAMALINGAM
ADA FILE
Data Structure in C Programming Language
Data Structure using C
DataStructures notes
C programming array & shorting

What's hot (20)

DOC
Basic c programs updated on 31.8.2020
PDF
Datastructures asignment
DOCX
Data Structures Using C Practical File
DOC
Daa practicals
PDF
design and analysis of algorithm Lab files
DOC
C basics
PPT
All important c programby makhan kumbhkar
DOC
Sorting programs
PPTX
Binary tree
DOCX
DAA Lab File C Programs
DOCX
Solutionsfor co2 C Programs for data structures
DOCX
DOCX
C lab manaual
PDF
Binary search
DOCX
SaraPIC
PPTX
4. chapter iii
PDF
Data Structures Practical File
PPTX
Double linked list
PDF
C programms
DOCX
Basic c programs updated on 31.8.2020
Datastructures asignment
Data Structures Using C Practical File
Daa practicals
design and analysis of algorithm Lab files
C basics
All important c programby makhan kumbhkar
Sorting programs
Binary tree
DAA Lab File C Programs
Solutionsfor co2 C Programs for data structures
C lab manaual
Binary search
SaraPIC
4. chapter iii
Data Structures Practical File
Double linked list
C programms
Ad

Viewers also liked (15)

PDF
Are pocket structures
PPTX
Are your analytic tools really adding value?
PDF
PDF
ภาษาไทย
PDF
Garcinia Cambogia: il nuovo estratto miracoloso per perdere peso velocemente....
PDF
Garcinia Cambogia: il nuovo estratto miracoloso per perdere peso velocemente....
PDF
Women in Agile - Agile 2014
PDF
Smgr corp presentation june 2014
PDF
Garcinia cambogia: nuovo estratto miracoloso per perdere peso velocemente. Tu...
PPTX
Portfolio
PPTX
Control de calidad
PPTX
Dynamo North East skills update January 2015 final BP
PDF
Mobile publishing bringing the book to SA teens
PPTX
Pharma Wikipedia Brand Pages
Are pocket structures
Are your analytic tools really adding value?
ภาษาไทย
Garcinia Cambogia: il nuovo estratto miracoloso per perdere peso velocemente....
Garcinia Cambogia: il nuovo estratto miracoloso per perdere peso velocemente....
Women in Agile - Agile 2014
Smgr corp presentation june 2014
Garcinia cambogia: nuovo estratto miracoloso per perdere peso velocemente. Tu...
Portfolio
Control de calidad
Dynamo North East skills update January 2015 final BP
Mobile publishing bringing the book to SA teens
Pharma Wikipedia Brand Pages
Ad

Similar to Data structure output 1 (20)

PDF
DATA STRUCTURE USING C & C++
PDF
DSU C&C++ Practical File Diploma
DOC
Final ds record
DOC
Main ds manual
PDF
Data Structure
PDF
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
DOCX
Data structure new lab manual
DOCX
DOCX
One dimensional operation of Array in C- language
PDF
VTU DSA Lab Manual
PDF
Data structure singly linked list programs VTU Exams
DOCX
Data Structure Project File
PDF
Array data structure
DOC
A sorted linear array
PDF
Array data structure
DOCX
PDF
Practical_File_Of_Data_Structure.pdf
PDF
VTU Data Structures Lab Manual
DATA STRUCTURE USING C & C++
DSU C&C++ Practical File Diploma
Final ds record
Main ds manual
Data Structure
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
Data structure new lab manual
One dimensional operation of Array in C- language
VTU DSA Lab Manual
Data structure singly linked list programs VTU Exams
Data Structure Project File
Array data structure
A sorted linear array
Array data structure
Practical_File_Of_Data_Structure.pdf
VTU Data Structures Lab Manual

Recently uploaded (20)

PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Types and Its function , kingdom of life
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O7-L3 Supply Chain Operations - ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
GDM (1) (1).pptx small presentation for students
VCE English Exam - Section C Student Revision Booklet
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Structure & Organelles in detailed.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Types and Its function , kingdom of life
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

Data structure output 1

  • 1. 1. INSERTION AND DELETION PROGRAM: #include<stdio.h> void main() { int n,c,a,value,position,array[50]; clrscr(); printf("Enter the number of elements in arrayn"); scanf("%d",&n); printf("Enter the %d elements n",n); for(c=0;c<n;c++) scanf("%d",&array[c]); printf("1.Insertiont2.Deletionn"); scanf("%d",&a); if(a==1) { printf("Enter the location where you wish to insert elementn"); scanf("%d",&position); printf("Enter the value to insertn"); scanf("%d",&value); for(c=n-1;c>=position-1;c--) array[c+1]=array[c]; array[position-1]=value; printf("Array is"); for(c=0;c<=n;c++) printf("%dt",array[c]); getch(); } else { printf("Enter the location where you wish to delete elementn"); scanf("%d",&position); if(position>=n+1) printf("Deletion not posiblen"); for(c=position-1;c<n;c++) array[c]=array[c+1]; printf("Array after deletion isn"); for(c=0;c<n-1;c++) printf("%dt",array[c]); getch(); } }
  • 2. OUTPUT: Enter the number of elements in array 5 Enter the 5 elements 2 4 6 8 10 1.Insertion 2.Deletion 1 Enter the location where you wish to insert element 4 Enter the value to insert 7 Array is 2 4 6 7 8 10 Enter the number of elements in array 5 Enter the 5 elements 2 4 6 8 10 1.Insertion 2.Deletion 2 Enter the location where you wish to delete element 4 Array after deletion is 2 4 6 10
  • 3. 2. MERGING TWO SORTED ARRAYS PROGRAM: #include<stdio.h> voidmain() { inta[50],b[50],c[100],m,n,i,j,k=0; clrscr(); printf("nEntersize of array A:n"); scanf("%d",&m); printf("nEntersortedelementsof arrayA:n"); for(i=0;i<m;i++) { scanf("%d",&a[i]); } printf("nEntersize of arrayB:n"); scanf("%d",&n); printf("nEntersortedelementsof arrayB:n"); for(i=0;i<n;i++) { scanf("%d",&b[i]); } i=0; j=0; while(i<m&&j<n) { if(a[i]<b[j]) { c[k]=a[i]; i++; } else { c[k]=b[j]; j++; } k++; } if(i>=m) { while(j<n) { c[k]=b[j];
  • 4. j++; k++; } } if(j>=n) { while(i<m) { c[k]=a[i]; i++; k++; } } printf("nAftermerging:n"); for(i=0;i<m+n;i++) { printf("n%d",c[i]); } getch(); } OUTPUT: Enter sorted elements of array A: 2 4 6 8 Enter size of array B: 4 Enter sorted elements of array B: 1 3 5 7 After merging: 1 2 3 4 5 6 7 8
  • 5. 3. SEARCHING AN ELEMENT IN 2-D ARRAY PROGRAM: #include<stdio.h> #include<conio.h> voidmain() { inta[20][20],i,j,m,n,pos,item; char f; int*p=&a[0][0]; clrscr(); printf("Enterthe numberof row n"); scanf("%d",&m); printf("Enterthe numberof column n"); scanf("%d",&n); printf("Enterthe dataone byone in row wise n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&a[i][j]); } printf("Enterthe searchitem n"); scanf("%d",&item); for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(a[i][j]==item) { p=p+(i*n+j)*16; f='y'; printf("The searchitem%disinposition[%d][%d]",item,i,j); printf("nTheaddressof the searchitem%dis%u",item,p); break; } } } if(f!='y') printf("nThesearchitem%disnotpresentinthe array",item); getch(); }
  • 6. OUTPUT: Enter the numberof row 4 Enter the numberof column 3 Enter the data one by one inrow wise 2 4 6 8 10 12 14 16 18 20 22 24 Enter the searchitem 12 The search item12 isin position[1][2] The addressof the searchitem12 is 64876
  • 7. 4. STACK OPERATION USING ARRAY PROGRAM: #include<stdio.h> #include<conio.h> #define n 10 struct stack { int top; int data[n]; }; void main() { struct stack s; int i,opt,item; clrscr(); s.top=-1; do { printf("n1.Pushn"); printf("2.Popn"); printf("3.Listn"); printf("4.Exitn"); printf("Enter any one optionn"); scanf("%d",&opt); switch(opt) { case 1:if(s.top==n-1) printf("Stack Fulln"); else { printf("Enter the data to push into the stackn"); scanf("%d",&item); s.top=s.top+1; s.data[s.top]=item; } break; case 2:if(s.top==-1) printf("Stack emptyn"); else { printf("The deleted element from stack is %d",s.data[s.top]);
  • 8. s.top--; } break; case 3:if(s.top==-1) printf("n stack empty"); else { printf("The elements in the stack aren"); for(i=s.top;i>=0;i--) printf("n%dn",s.data[i]); } break; } } while(opt!=4); getch(); }
  • 9. OUTPUT: 1.Push 2.Pop 3.List 4.Exit Enter any one option 1 Enter the data to push into the stack 10 1.Push 2.Pop 3.List 4.Exit Enter any one option 1 Enter the data to push into the stack 20 1.Push 2.Pop 3.List 4.Exit Enter any one option 1 Enter the data to push into the stack 30 1.Push 2.Pop 3.List 4.Exit Enter any one option 3 The elements in the stack are 30 20 10
  • 10. 1.Push 2.Pop 3.List 4.Exit Enter any one option 2 The deleted element from stack is 30 1.Push 2.Pop 3.List 4.Exit Enter any one option 2 The deleted element from stack is 30 1.Push 2.Pop 3.List 4.Exit Enter any one option 3 The elements in the stack are 20 10 1.Push 2.Pop 3.List 4.Exit Enter any one option 4
  • 11. 5. CONVERTING INFIX EXPRESSION TO POSTFIX EXPRESSION PROGRAM: #include<stdio.h> #include<conio.h> struct stack { intdata[50]; inttop; }; struct stack s; char infix[50],post[50]; voidpostfix(); voidpush(int); char pop(); voidmain() { clrscr(); printf("Enterthe infix expressionn"); scanf("%s",infix); postfix(); getch(); } voidpostfix() { inti,j=0; for(i=0;infix[i]!='0';i++) { switch(infix[i]) { case'+': while(s.data[s.top]>=i) post[j++]=pop(); push(1); break; case'-': while(s.data[s.top]>=1) post[j++]=pop(); push(2); break; case'*': while(s.data[s.top]>=3)
  • 13. c='+'; break; case 2: c='-'; break; case 3: c='*'; break; case 4: c='/'; break; case 5: c='^'; break; } return(c); } OUTPUT: Enter the infix expression (a+b*c-d/e) The postfix expressionis abc*+de/-
  • 14. 6. EVALUATING A POSTFIX EXPRESSION PROGRAM: #include<stdio.h> #include<conio.h> #include<math.h> #include<ctype.h> struct stack { inttop; floata[20]; }s; voidmain() { inti,n; floatopt1,opt2,opt3; char ex[20]; clrscr(); s.top=-1; printf("nEnterthe postfix expression:"); gets(ex); n=strlen(ex); for (i=0;i<n;i++) { if (isdigit(ex[i])) { s.top++; s.a[s.top]=ex[i]-'0'; } else { opt2=s.a[s.top--]; opt1=s.a[s.top--]; switch(ex[i]) { case'+': opt3=opt1+opt2; break; case'-': opt3=opt1-opt2; break; case'*':
  • 16. 7. QUEUE OPERATIONS USING ARRAY PROGRAM: #include<stdio.h> #include<conio.h> struct queue { intdata[50]; intfront; intrear; }; inti,opt,item; intx; voidmain() { struct queue q; clrscr(); q.front=-1; q.rear=-1; do { printf("Selectanyone option n"); printf("1.Create n"); printf("2.Listn"); printf("3.Insert n"); printf("4.Deleten"); printf("5.Exitn"); scanf("%d",&opt); switch(opt) { case 1: printf("Enter10data one by one n"); for(i=0;i<10;i++) scanf("%d",&q.data[++q.rear]); break; case 2: printf("The datainthe queue are n"); for(i=q.front+1;i<=q.rear;i++) printf("%dn",q.data[i]); break; case 3: printf("Enterthe datatoinsert n");
  • 18. OUTPUT: Selectanyone option 1.Create 2.List 3.Insert 4.Delete 5.Exit 1 Enter 10 data one byone 1 2 3 4 5 6 7 8 9 10 Selectanyone option 1.Create 2.List 3.Insert 4.Delete 5.Exit 3 Enter the data to insert 11 1.Create 2.List 3.Insert 4.Delete 5.Exit 2 The data in the queue are 1 2 3 4 5
  • 19. 6 7 8 9 10 11 Selectanyone option 1.Create 2.List 3.Insert 4.Delete 5.Exit 4 The deleateditemis 1 Selectanyone option 1.Create 2.List 3.Insert 4.Delete 5.Exit 4 The deleateditemis 2 Selectanyone option 1.Create 2.List 3.Insert 4.Delete 5.Exit 5