Hi guys,i am new to both c++ and this forum...I got a problem with a question i m supposed to do.I am supposed to create a queue system but i am stuck at a point where i can't add numbers to the queue system.This is the question...
You have been assigned to code the world longest queue that can store up to a maximum of 10 integers.
Create a queue system interface with the following functionalities:
- option to Add number to end of queue
- option to Remove number from end of queue
- option to Sort queue in ascending order
- option to Show queue content
- quit
Sample Output:
Queue System [Free: 10]
==================================
1. Add number to end of queue
2. Remove number from end of queue
3. Sort queue in ascending order
4. Show queue content
5. Quit
Choice: 1
Enter the number to add: 10
The problem is that i can't add number to the queue.Here is my code...
# include<iostream>
using namespace std;
void show(int a[],int size)
{
for(int b=0;b<=size;b++)
{
cout<<"Item "<<b<<": "<<a[1]<<endl;
}
}
void subno(void)
{
int sub=0,b=0,c=0;
cout<<"Status: Last number successfully removed."<<endl;
}
void addno(void)
{
int arr[10];
int b=0;
cout<<"Enter number to add: ";
for(int i=0; ;i++)
{
cin>>arr[i];
}
}
void main(void)
{
int b=10,c=0,e=0;
int a=0;
do
{
cout<<"Queue system [Free:"<<b<<"]"<<endl;
for(int f=1;f<36;f++)
{
cout<<"=";
}
cout<<endl;
cout<<"1. Add number to the end of queue."<<endl;
cout<<"2. Remove number from end of queue."<<endl;
cout<<"3. sort the queue in ascending order."<<endl;
cout<<"4. show queue content."<<endl;
cout<<"5. Quit."<<endl;
cout<<"choice: ";
cin>>a;
cout<<endl;
if(a==1)
{
addno();
b--;
}
else if(a==2)
{
subno();
b++;
}
}
while(b!=0);
}
i don't know how to add number to the array.