CPP

CPP

Sequences has 9 Questions
How many items are there in sequence container?

2
3
4
5
Which of the following class template are based on arrays?

vector
list
dequeue
Both a & c
Which of the following will return the new element at the end of container?

front
back
push_back
pop_back
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         deque<int> mydeque (5);  
  7.         deque<int>::reverse_iterator rit = mydeque.rbegin();
  8.         int i = 0;
  9.         for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit)
  10.             *rit = ++i;
  11.         for (deque<int> :: iterator it = mydeque.begin();
  12.         it != mydeque.end(); ++it)
  13.         cout << ' ' << *it;
  14.         return 0;
  15.     }

12345
1234
54321
43210
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         unsigned int i;
  7.         deque<int> mydeque;
  8.         mydeque.push_back (100);
  9.         mydeque.push_back (200);
  10.         mydeque.push_back (300);
  11.         for(deque<int> :: iterator it = mydeque.begin(); it != mydeque.end(); ++it)
  12.         {
  13.         }
  14.         mydeque.clear();
  15.         mydeque.push_back (110);
  16.         mydeque.push_back (220);
  17.         for(deque<int> :: iterator it = mydeque.begin(); it != mydeque.end(); ++it)
  18.             cout << ' ' << *it;
  19.         cout << '\n';
  20.         return 0;
  21.     }

110
220
Both a & b
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int main ()
  5.     {
  6.         vector<int> myvector;
  7.         int * p;
  8.         unsigned int i;
  9.         p = myvector.get_allocator().allocate(5);
  10.         for (i = 0; i < 5; i++) 
  11.             myvector.get_allocator().construct(&p[i], i);
  12.         for (i = 0; i < 5; i++)
  13.             cout << ' ' << p[i];
  14.         for (i = 0; i < 5; i++)
  15.             myvector.get_allocator().destroy(&p[i]);
  16.         myvector.get_allocator().deallocate(p, 5);
  17.         return 0;
  18.     }

1 2 3 4 5
0 1 2 3 4
1 2 3 4
5 4 3 2 1
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     bool same_integral_part (double first, double second)
  6.     {  
  7.         return ( int(first) == int(second) ); 
  8.     }
  9.     struct is_near 
  10.     {
  11.         bool operator() (double first, double second)
  12.         { 
  13.             return (fabs(first - second) < 5.0); 
  14.         }
  15.     };
  16.     int main ()
  17.     {
  18.         double mydoubles[] = { 12.15,  2.72, 73.0,  12.77,  3.14, 12.77, 73.35, 72.25, 15.3,  72.25 };
  19.         list<double> mylist (mydoubles, mydoubles + 10);
  20.         mylist.sort();
  21.         mylist.unique();
  22.         mylist.unique (same_integral_part);
  23.         mylist.unique (is_near());
  24.         for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
  25.             cout << ' ' << *it;
  26.         cout << '\n';
  27.         return 0;
  28.     }

2.72 12.15 72.25
12.15 73.0 12.77
73.35
None of the mentioned
How the list containers are implemented?

Using Double linked list
Using Single linked list
Both a & b
None of the mentioned
Which of the following does not support any insertion or deletion?

Array
Vector
Dequeue
List