Test Series - cpp

Test Number 86/102

Q: Which keyword is used to declare the min and max functions?
A. iostream
B. string
C. algorithm
D. iterator
Solution: Algorithm header file contains the supporting files needed for the execution of these functions.
Q: What kind of functions are min and max in c++?
A. Type specific
B. Variable specific
C. Type & Variable specific
D. Iterator
Solution: The min/max functions are type specific but they will not force everything to be converted to/from floating point. The functions that will force everything to be converted to/from floating point are fmin/fmax.
Q: How many parameters are needed for minmax function?
A. 1
B. 2
C. 3
D. All of the mentioned
Solution: The “minmax” function can take the following:
1 parameter: An initializer_list object.
2 parameters: Values to compare.
2 parameters: An initializer_list object. and comparison function
3 parameters: Values to compare. and comparison function
Q: Which function is used to return the minimum element in the range?
A. min
B. minimum
C. min_element
D. max_element
Solution: The min_element is used to compare the range of elements and it can find out the minimum element.
Q: Which operator is used to compare the values to find min and max?
A. <
B. >
C. <<
D. >>
Solution: Less than(<) operator is sufficient to compare any two elements in heap and construct respective min or max heap accordingly.
Q: What is meant by permutation in c++?
A. To find all the values in the range
B. To find all the combination of the range
C. To find all the values & combination in the range
D. To delete all the values
Solution: The permutation is used to find all the combination of numbers in the range.
Q: How the different permutations are ordered in c++?
A. Compare lexicographically to each other elements
B. By finding the highest element in the range
C. By finding the lowest element in the range
D. By deleting the lowest element in the range
Solution: In c++ permutations can be ordered by comparing lexicographically to each other elements.
Q: Pick out the correct statement about permutation.
A. If the function can determine the next higher permutation, Returns false
B. If the function can determine the next higher permutation, Returns true
C. If the function can’t determine the next higher permutation, Returns true
D. If the function can determine the lower higher permutation, Returns true
Solution: If the function can determine the next higher permutation, it rearranges the elements as such and returns true.
Q: What is the header file for vector permutation?
A. vector_permutation.h
B. vector_perm
C. 
D. vector_permutation
Solution: To use permutation on a vector we can use the “next_permutation” function defined in the header.
Q: How many parameters are required for next_permutation?
A. 1
B. 2
C. 2 or 3
D. 3
Solution: There are 2 or 3 needed for next_permutation. They are first, last and optional comp for comparing the elements.

You Have Score    /10