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 num[] = { 12, 25, 39 ,42 };
    int * ptr;
    ptr = find (num, num + 4, 42);
    --ptr;
    cout << *ptr << '\n';
    return 0;
    }
    1. 12
    2. 25
    3. 39
    4. 42
    5. Compilation Error
Correct Option: C

In this program, We used the find method to find the value before 42.



Your comments will be displayed only after manual approval.