Skip to main content

QUEUE


QUEUE
 //QUEUE
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
typedef struct stk
{
int info;
struct stk *link;
}node;
node *start;
void create()
{
printf("\n'Create' Function Called\n");
start=NULL;
}
void enqueue()
{

node *ptr;
int i;
ptr=(node*)malloc(sizeof(node));
printf("\nEnqueue Value: ");
scanf("%d",&i);
ptr->info=i;
ptr->link=start;
start=ptr;
}

void display()                         //DISPLAY
{
node *ptr;
printf("\n\n'Display' Function Called");
ptr=start;
if(start==NULL)
{
printf("\n*Queue Empty 'Underflow'*");
}else
{
while(ptr->link!=NULL)
{
printf("\nInfo= %d",ptr->info);
ptr=ptr->link;
}
printf("\nInfo= %d",ptr->info);
}
printf("\n");
getch();
}
void dequeue()
{
int p;
node *ptr,*ptr1;
printf("\n'Dequeue' Function Called");
ptr=start;
if(start==NULL)
{
printf("\n*Queue Empty 'Underflow'*");
}else
{
if(ptr->link==NULL)
{
start=NULL;
}
while(ptr->link!=NULL)
{
ptr1=ptr;
ptr=ptr->link;
}
ptr1->link=NULL;
}
display();
}
void main()
{
clrscr();
create();
enqueue();
enqueue();
enqueue();
enqueue();
display();
dequeue();
dequeue();
dequeue();
dequeue();
printf("\t\t**END**");
getch();
}

***********************************************************************************

Sample Output:








Comments

Popular posts from this blog

CAREER OPTIONS AFTER BCA

Career Options after BCA There are several doors opened, once you are done with your bachelor's in computer application(BCA).Apart from MCA or MBA in IT , one can also go for :  Masters in Computer Management  Masters Degree in Information Management (MIM)  Master of Science in Information Technology (M.Sc IT)  G-CAT Master  Postgraduate Diploma in Computer Applications  Post Graduate Program in Corporate Studies (PGPCS)  Postgraduate Diploma in Management (PGDM)  Program in Information Security Management  If one wants to get recruited and desires to be the part of corporate sector....there are numerous options for that too. One can work as a software developer, web developer, graphic Designer, App Developer for

SYLLABUS OF THE CDS EXAMINATION 2017

B. STANDARD AND SYLLABUS OF THE EXAMINATION  The standard of the papers in Elementary Mathematics will be of Matriculation level. The standard of papers in other subjects will approximately be such as may be expected of a graduate of an Indian University. SYLLABUS: ENGLISH (Code No. 01)  The question paper will be designed to test the candidates’ understanding of English and workmanlike use of words. GENERAL KNOWLEDGE (Code No. 02)  General Knowledge including knowledge of current events and of such matters of everyday observation and experience in their scientific aspects as may be expected of an educated person who has not made a special study of any scientific subject. The paper will also include questions on History of India and Geography of a nature which candidate should be able to answer without special study. ELEMENTARY MATHEMATICS (Code No. 03)  ARITHMETIC  Number System—Natural numbers, Integers, Rational and Real numb...

PROJECT MANAGEMENT AND SYSTEM DEVELOPMENT

SECTION-A    1. Concept of a Project, Project Life Cycle Phases, Tools & Techniques of Project Management, Roles & Responsibilities of a Project Manager, Feasibility Report, Types of Feasibility, Financing Arrangements, Preparation of Cost Estimates, Project Implementation Schedule, Evaluation of Project Profitability. SECTION-B  2. Working & Design of Systems, System Design & Execution Plan, Work Breakdown Structure, Project Procedure Manual, Planning, Scheduling & Monitoring, Project Direction & Co- ordination, Communications in a Project, Project Control-Progress, Performance, Schedule & Cost Control, Performance Indicators & Performance Improvement, Project Management Environment.