Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

A circular queue can be implemented through arrays or linked lists. Program 6 gives the array implementation of any circular queue.

Program 6: Array implementation of any Circular queue

include "stdio.h"

void add(int);

void deleteelement(void);

int max=10;         /*the maximum limit for queue has been set*/

static int queue[10];

int front=0, rear=-1; /*queue is initially empty*/

void main()

{

int choice,x;

printf ("Enter # for insertion & $ for removal of front the queue and * for exit");

printf("Enter your choice");

 scanf("%d",&choice);

switch (choice)

{

case 1 :

printf ("Enter element for insertion in queue:");

scanf("%d",&x);

add(x);

break;

case 2 :

deleteelement();

break;

}

}

void add(int y)

{

if(rear == max-1)

rear = 0;

else

rear = rear + 1;

if( front == rear && queue[front] != NULL)

printf("Queue Overflow");

else

queue[rear] = y;

}

void deleteelement()

{

int deleted_front = 0;

if (front == NULL)

printf("Error - Queue empty");

else

{

deleted_front = queue[front];

queue[front] = NULL;

if (front == max-1)

front = 0;

else

front = front + 1;

}

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9619074

Have any Question?


Related Questions in Computer Engineering

Service set identifier ssid also known as the wireless

Service Set Identifier (SSID), also known as the wireless network name, identifies the wireless network. An SSID is configured on the wireless AP (on the access point for the infrastructure mode) or on an initial wireles ...

Explain a business process you are familiar with describe

Explain a business process you are familiar with. Describe how a computer-based information system is related (or used) in this business process. Explain how a computer-based information systems can improve the efficienc ...

These questions are for unix linuxselect the lines from

THESE QUESTIONS ARE FOR UNIX (LINUX) Select the lines from file file1 that have exactly three characters in them. Select the lines from file file1 that have at least three characters in them. Select the lines from file f ...

From a security standpoint do you believe the apple

From a security standpoint, do you believe the Apple approach of hiding permissions or the Android approach of requiring the user to accept application permissions is a better approach? Why do you feel this way and do yo ...

You own a specialty company self made company smc which

You own a specialty company; self made company (SMC) which sells hats and jackets. You obtained an object IDENTIFIER 5000 under enterprises node from IANA. You have two branch locations. Each has an inventory system that ...

Question summarize the process of how cameras and scanners

Question : Summarize the process of how cameras and scanners produce digital images. Compare differences between the production of images on film and digital images.

Assembly programs use 32 bits to address memory and can

Assembly programs use 32 bits to address memory and can access up to 4gb of memory. If an assembly code for a system uses 16 bits to address memory, how many bytes of memory can the program access? Is it as simple as 2^1 ...

What is the fraction defective if material hardness is

What is the fraction defective if material hardness is normally distributed with a mean of 42 and a standard deviation of 1 and the specification limits for hardness are from 35 to 45? What value for the process mean wil ...

Stockholdingwrite a class stockholding the purpose of a

StockHolding Write a class StockHolding. The purpose of a StockHolding object is to represent a single stock in someone's investment portfolio. The StockHolding class has the following specification: instance variable of ...

Recursive greatest common divisor the greatest common

(Recursive Greatest Common Divisor) The greatest common divisor of integers x and y is the largest integer that evenly divides both x and y. what is a recursive function gcd that returns the greatest common divisor of x ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As