In C++, for what purpose is the “rank()” used?

2023

In C++, for what purpose is the “rank()” used?

  1. A.

    It returns the size of each dimension

  2. B.

    It returns the maximum number of elements that can be stored in the array

  3. C.

    It returns the dimension of the specified array

  4. D.

    More than one of the above

  5. 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 है: यह निर्दिष्ट एरे के आयाम की संख्या लौटाता है।

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs