Functions
- Where does the execution of the program starts?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Normally the execution of the program in c++ starts from main only.
- What is the output of this program?
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main ()
{
int num[] = {5, 10, 11};
int Remainder[4];
transform ( num, num + 4, Remainder,
bind2nd(modulus<int>(), 2) );
for (int k = 0; k < 4; k++)
cout << (Remainder[k] == 1 ? "Odd" : "Even") << "\n";
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Running the program will show above behaviour because we have given the value in for loop as 4 instead of 3.
- What is the output of this program?
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
cout << min(200, 201) << ' ';
cout << min('U','L') << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We are finding the minimum value by using min method.
- What is the output of this program?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int num[] = {15, 25, 35, 35, 25, 15, 15, 25};
vector<int> VectorData(num, num + 8);
sort (VectorData.begin(), VectorData.end());
vector<int> :: iterator Lower, Upper;
Lower = lower_bound (VectorData.begin(), VectorData.end(), 35);
Upper = upper_bound (VectorData.begin(), VectorData.end(), 35);
cout << (Lower - VectorData.begin()) << ' ';
cout << (Upper - VectorData.begin()) << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, We are finding the upper bound and lower bound values by using lower_bound and upper_bound methods.
- What is the output of this program?
#include <iostream>
#include <algorithm>
using namespace std;
bool Function(int k, int L)
{
return k < L;
}
int main ()
{
int Array[ ] = {31, 17, 12, 51, 16, 14};
cout << *min_element(Array, Array + 6, Function) << " ";
cout << *max_element(Array, Array + 6, Function) ;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We found out the minimum value and maximum value of a range.