ExamVeda
Login
Home
81
Why we use :: template-template parameter?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
82
What will be the output of the following C++ code?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
	vector <int> v = {1,5,23,90,15,35};
	cout<<is_heap(v.begin(), v.end());
	make_heap(v.begin(), v.end());
	cout<<is_heap(v.begin(), v.end());
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
83
What is used to write multi line comment in c++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
84
What will be the output of the following C++ code?
#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int myop (int x, int y) 
{
    return x + y + 1;
}
int main () 
{
    int val[] = {1, 2, 3, 4, 5};
    int result[5];
    partial_sum (val, val + 5, result);
    for (int i = 0; i < 5; i++)
        cout << result[i] << ' ';
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
85
Which of the following is correct about tuples?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
86
How many bits of memory needed for internal representation of class?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
87
How many types of class are there in c++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
88
What will be the output of the following C++ code?
#include <iostream>
#include <ios>
#include <istream>
#include <limits>
using namespace std;
template <typename CharT>
void ignore_line ( basic_istream<CharT>& in )
{
    in.ignore ( numeric_limits<streamsize> :: max(), in.widen ( '\n' ) );
}
int main()
{
    cout << "First input: ";
    cin.get();
    cout << "Clearing cin.\n";
    cin.clear();
    ignore_line ( cin );
    cout << "All done.\n";
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
89
What will be the output of the following C++ code?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void Display(const vector<int>& vi)
{
    for (size_t i = 0; i < vi.size(); ++i)
        cout << vi[i];
    cout<<endl;
}
int main()
{
    vector<int> vi;
    vi.push_back(3);
    vi.push_back(5);
    sort(vi.begin(), vi.end());
    Display(vi);
    while(next_permutation(vi.begin(), vi.end()))
    Display(vi);
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
Solution:
The C++ code uses the STL functions sort() and next_permutation() to display permutations of a vector.

Initially, the vector vi contains two elements: 3 and 5.

The sort(vi.begin(), vi.end()) function arranges the elements in ascending order, so the first output will be 3 5.

Then, the next_permutation() function rearranges the vector to the next lexicographical permutation, which will be 5 3, and it is displayed after sorting.

After this, there are no more permutations, so the loop terminates.

Thus, the output will be: 5 3 3 5.
90
Pick out the correct statement about string template.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board