In C++, for what purpose is the “rank()” used?
2023
In C++, for what purpose is the “rank()” used?
- A.
It returns the size of each dimension
- B.
It returns the maximum number of elements that can be stored in the array
- C.
It returns the dimension of the specified array
- D.
More than one of the above
- E.
None of the above
Attempted by 230 students.
Show answer & explanation
Correct answer: C
In C++, the rank() function is used to determine the number of dimensions of an array or container. For example, a 1D array has rank 1, a 2D array has rank 2, and so on.
It does not return the size of each dimension (Option A), nor the maximum number of elements (Option B), nor does it return more than one of the above (Option D).
The correct answer is Option C: It returns the dimension of the specified array.
हिन्दी उत्तर:
C++ में rank() फ़ंक्शन का उपयोग एक एरे या कंटेनर के आयामों की संख्या ज्ञात करने के लिए किया जाता है। उदाहरण के लिए, 1D एरे का रैंक 1 होता है, 2D एरे का रैंक 2 होता है, आदि।
यह आयाम के प्रत्येक आकार (Option A) या अधिकतम तत्वों की संख्या (Option B) नहीं लौटाता है, और यह उपर्युक्त में से एक से अधिक नहीं लौटाता (Option D)।
सही उत्तर Option C है: यह निर्दिष्ट एरे के आयाम की संख्या लौटाता है।