CPP

CPP

Nonmodifying Sequence Algorithms has 8 Questions

How does a sequence of objects are accessed in c++?

Iterators
Pointers
Both a & b
None of the mentioned
How many parameters are present in mismatch method in non-sequence modifying algorithm?

1
2
3
3 or 4
What will happen in 'all_of' method if the range is empty?

Return true
Return false
Return nothing
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     #include 
  5.     using namespace std;
  6.     bool mypredicate (int i, int j)
  7.     {
  8.         return (i == j);
  9.     }
  10.     int main () 
  11.     {
  12.         vector<int> myvector;
  13.         for (int i = 1; i < 6; i++) myvector.push_back (i * 10);
  14.         int myints[] = {10, 20, 30, 40, 1024};
  15.         pair<vector<int> :: iterator, int*> mypair;
  16.         mypair = mismatch (myvector.begin(), myvector.end(), myints);
  17.         cout  << *mypair.first<<'\n';
  18.         cout  << *mypair.second << '\n';
  19.         ++mypair.first; ++mypair.second;
  20.         return 0;
  21.     }

40 1024
50 1024
20 1024
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int main () 
  6.     {
  7.         vector<int> myvector;
  8.         for (int i = 1; i < 5; ++i)
  9.             myvector.push_back(i);
  10.         rotate(myvector.begin(), myvector.begin() + 3, myvector.end( ));
  11.         for (vector<int> :: iterator it = myvector.begin(); 
  12.             it != myvector.end(); ++it)
  13.         cout << ' ' << *it;
  14.         return 0;
  15.     }

1 2 3 4
4 3 2 1
3 4 2 1
4 1 2 3
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int main ()
  6.     {
  7.         int myints[] = {10, 20, 30, 30, 20, 10, 10, 20};
  8.         int mycount = count (myints, myints + 8, 10);
  9.         cout << mycount;
  10.         vector<int> myvector (myints, myints + 8);
  11.         mycount = count (myvector.begin(), myvector.end(), 20);
  12.         cout << mycount;
  13.         return 0;
  14.     }

33
44
22
None of the mentioned
To what kind of elements does non-modifying sequence algorithm can be applied?

Range
Vector
List
All of the mentioned
Pick out the incorrect method in non-modifying sequence algorithm?

find-if
none-of
any-of
like