Test Series - cpp

Test Number 74/102

Q: What is a Random number generator?
A. A generator that generates deterministic random numbers
B. A generator that generates both non-deterministic random numbers and deterministic random numbers
C. A generator that generates non-deterministic random numbers
D. A generator that generates a simple random number
Solution: Random number generator is a random number generator which generates non-deterministic random numbers.
Q: What is random_device?
A. A pseudo-random number generator
B. Time-dependent random number generator
C. Simple random number generator
D. A true random number generator
Solution: random_device is a true random number generator not the pseudo random number generator.
Q: Which algorithm is used in subtract_with_carry_engine?
A. Mersenne Twister algorithm
B. Lagged fibonacci generator algorithm
C. Either the Mersenne Twister algorithm or Lagged fibonacci generator algorithm
D. Fibonacci generator
Solution: The algorithm used in subtract_with_carry_engine is lagged fibonacci generator, with state sequences.
Q: How many Engine Adaptors are there in C++?
A. 1
B. 2
C. 3
D. 4
Solution: There are three types of Engine adaptors in C++, namely discard_block_engine, independent_bits_engine and shuffle_order_engine.
Q: Which of the header file is used for array type manipulation?
A. 
B. 
C. 
D. std namespace
Solution: Array type manipulation functions are declared incside the namespace std so you can use namespace std to use these functions.
Q: What is the use of is_same() function in C++?
A. To check if a variable is array type or not
B. To check whether two variables have the same characteristics
C. To check if two variable is of array type or not
D. To check whether two variables are different or not
Solution: is_same() function is used to check whether two variables have the same characteristics or not.
Q: What is the use of rank() function in C++?
A. Returns size of each dimension
B. Returns how many total elements can be stored in an array
C. Returns how many elements are in array currently
D. Returns the dimension of an array
Solution: rank() function returns the rank of the array i.e. the dimension of an array. For example, int arr[10][10] has rank 2.
Q: Which of the following is correct about extent() function?
A. Returns how many elements are in array currently
B. Returns the size of the 1st dimension
C. Returns how many total elements can be stored in an array
D. Returns the size of a given dimension
Solution: The extent() function takes two parameters one denoting the array other showing the dimension for which the size we want to know.
Q: Which of the following is correct about remove_extent() function?
A. Removes the given dimension from an array
B. Removes the first dimension from the right of the array
C. Removes the first dimension from the left of the array
D. Removes the last dimension from the left of the array
Solution: remove_extent() function removes the first dimension i.e. the first dimension from the given array.
Q: Which of the following is correct about remove_all_extents() function?
A. Removes the all dimension from an array
B. Removes the first dimension from the left of the array
C. Removes the first dimension from the right of the array
D. Removes the last dimension from the left of the array
Solution: As the name suggests remove_all_extent() function removes all the dimensions from the array. So rank os array after this operation becomes 0.

You Have Score    /10