A queue is a linear data structure in which one end is always used to insert data (enqueue) and the other is used to remove data (dequeue). The element inserted first will also be removed first.
Example:
1) The queue of processes in OS.
2) The queue of packets in data communication.
3) The queue of airplanes waiting for landing instructions.
Example:
1) A queue can be a single-lane one-way road, where the vehicle enters first, exits first.
2) A queue is the ticket windows and bus-stops
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int numbers[5];
int x; int a; int b; int sum; sum=0;
cout<<"press 1 for addition"<<endl;
cout<<"press 2 for show the value"<<endl;
cout<<"press 3 for exit the program"<<endl;
cout<<"Enter 1 to additional"<<endl;
cin>>x;
if(x==1)
{
cout<<"valid"<<endl;
cout<<"Enter the five numbers:"<<endl;
for(int i=0; i<5; ++i)
{
cin>>numbers[i];
sum+=numbers[i];
}
}
else
cout<<"invalid"<<endl;
{
cout<<"Enter 2 to show:"<<endl;
cin>>x;
if(x==2)
cout<<"valid"<<endl;
cout<<"the sum of total value:"<<sum<<endl;
}
cout<<"invalid"<<endl;
{
cout<<"Enter 3 to exit:"<<endl;
cin>>x;
if(x==3)
cout<<"valid"<<endl;
return 0;
}
}
0 comments: