How to check if queue is empty or not in C++

1 Answer

0 votes
#include <iostream>
#include <queue>
  
using namespace std; 
    
int main() 
{ 
    queue<int> q;
    int array[5] = {1, 7, 3, 5, 4};
      
    for (int i = 0; i < 5; i++) {
        q.push(array[i]);
    }
  
    if (q.empty()) { 
        cout << "True"; 
    } 
    else { 
        cout << "False"; 
    } 
} 
  
  
  
  
/*
run:
  
False
  
*/

 



answered Apr 5, 2020 by avibootz

Related questions

1 answer 206 views
1 answer 208 views
1 answer 252 views
5 answers 970 views
1 answer 172 views
1 answer 225 views
...