What will happen when you attempt to compile and run the following code?

Last Updated on May 22, 2022 by Admin 3

What will happen when you attempt to compile and run the following code?

#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int
main()
{
 int mynumbers[] = {8,9,7,6,4,1};
 vector<int>v1 (mynumbers, mynumbers+ 6); //LINE I
 cout<<*max_element(v1.begin(),v1.end()) <<", "; //LINE II
 return 0;
}
  • the program outputs 8,
  • the program outputs 1,
  • you can call max_element function on non ordered v1 vector
  • you can’t call max_element function on non ordered v1 vector
  • the program outputs 9,
  • runtime error at LINE II
  • compilation error in LINE I
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments