Question #4266

Write a program that will accept a list of integer number. The odd numbers will be stored into a queue call ODDQUEUE and the even number will be stored in different queue call EVENQUEUE.

this is under subject data structure and algorithm so the code might be almost same to c++ but it is different in it structure

Expert's answer


#include <iostream>
#include <queue>

using namespace
std;


int main()
{
queue<int> EVENQUEUE,
ODDQUEUE;

int n;
cout << "Total number of items: ";
cin
>> n;

int q, i;
for (i=0; i<n; i++)
{
cout <<
"a[" << i << "]= ";
cin >> q;
if (q %
2)
{
EVENQUEUE.push(q);
}
else
{
ODDQUEUE.push(q);
};
};
return
0;
};
LATEST TUTORIALS
APPROVED BY CLIENTS