Professional Documents
Culture Documents
TECHNICAL REPORT
ON
CSE302 ASSIGNMENT
SUBMITTED TO:
DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING
DECEMBER, 2021.
1
THE UNDERLISTED NAMES ARE THE MEMBER OF 300L GROUP 7
QUESTION
2
Stack and Queue are two important techniques in storing data in the computer's memory, do a
C# program that will implement the two using switch selection statement with options to
push onto the stack and POPfrom same
CODE
using System;
namespace StackQueueOperation
{
//+++ Start Stack class +++++
internal class Stack
{
static readonlyint MAX = 1000;
int top;
int[] stack = new int[MAX];
bool IsEmpty()
{
return (top < 0);
}
public Stack()
{
top = -1;
}
internal bool Push(int data)
{
if (top >= MAX)
{
Console.WriteLine("Stack Overflow");
return false;
}
else
{
stack[++top] = data;
return true;
}
}
public Queue(int c)
{
front = rear = 0;
capacity = c;
queue = new int[capacity];
}
// decrement rear
rear--;
}
Console.WriteLine("Dequeue Successfully");
return;
}
7
// int element =
Convert.ToInt32(Console.ReadLine());
// myqueue.queueEnqueue(element);
// }
do
{
Console.Clear();
Console.WriteLine("++++++++++++ Welcome to Queue Operations +++++++++++
++");
Console.WriteLine();
Console.WriteLine("1. Print Queue");
Console.WriteLine("2. Enqueue Element");
Console.WriteLine("3. Dequeue Element");
Console.WriteLine("4. Peek Front Element");
Console.WriteLine();
Console.WriteLine("Select operation to perform");
int select = Convert.ToInt32(Console.ReadLine());
switch (select)
{
case 1:
// print Queue elements
myqueue.queueDisplay();
break;
case 2:
// Insert Queue elements
Console.WriteLine("Enter the element to enqueue.");
intNewElement = Convert.ToInt32(Console.ReadLine());
myqueue.queueEnqueue(NewElement);
Console.WriteLine("After Equeuing, New Queue is:");
myqueue.queueDisplay();
break;
case 3:
// Delecting Queue elements
myqueue.queueDequeue();
Console.WriteLine("After Dequeuing, New Queue is:");
myqueue.queueDisplay();
break;
case 4:
// Displaying Queue front
element
myqueue.queueFront();
break;
default:
Console.WriteLine("Oops!... Selection out range!!..choose btw 1 and
4");
break;
}
Console.Write("\n\nDo you want to perform more stack operation?..Enter
Y for Yes, any key to exit: ");
ex = Console.ReadLine();
}
}
}
OUPUT
9
10
11