Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main ()
    {
    int Array[] = {100,200, 300, 300, 200, 100, 100, 200};
    int CountData = count (Array, Array + 8, 100);
    cout << "100 appears " << CountData << " times.\n";
    vector<int> VectorData (Array, Array+8);
    CountData = count (VectorData.begin(), VectorData.end(), 200);
    cout << "200 appears " << CountData << " times.\n";
    return 0;
    }
    1. 100 appears 3 times.
      200 appears 3 times.
    2. 100 appears 3 times.
    3. 200 appears 3 times.
      100 appears 3 times.
    4. 200 appears 3 times.
    5. None of these
Correct Option: A

In this program, We are counting the number of 100’s and 200’s in the Array.



Your comments will be displayed only after manual approval.