Understanding Two-Dimensional Arrays
10 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the correct way to initialize a 2D array in C++ to store roll number and marks obtained by 4 students side by side?

  • int arr[4][2]; (correct)
  • int arr[8];
  • int arr[][] = { {1, 85}, {2, 90}, {3, 78}, {4, 92} };
  • int arr[2][4];
  • In a 2D array, what does 'r' represent?

  • A specific element in the array
  • Number of columns in the matrix
  • Number of rows in the matrix (correct)
  • Total number of elements in the array
  • What does the following C++ code initialize? int arr = { { 1234, 56 }, { 1256, 43 }, { 1434, 32 }, { 1312, 96 } };

  • A 1D array with 8 elements
  • A 2D array with 4 rows and 2 columns
  • A matrix with dimensions 1234x56, 1256x43, 1434x32, and 1312x96
  • It is an invalid initialization for an array (correct)
  • What is the correct syntax to access an element at the third row and second column in a C++ 2D array 'arr'?

    <p>arr[2][1]</p> Signup and view all the answers

    What does 'c' represent in the declaration 'datatype array_name[r][c];' for a 2D array?

    <p>Number of columns in the matrix</p> Signup and view all the answers

    What is the correct way to initialize a 2D array in C++ to store roll number and marks obtained by 4 students side by side?

    <p>int arr[4][2] = {{101, 85}, {102, 90}, {103, 78}, {104, 92}};</p> Signup and view all the answers

    In a C++ 2D array declaration 'datatype array_name[r][c];', what does 'r' represent?

    <p>Number of rows in the matrix</p> Signup and view all the answers

    What does the following C++ code initialize?

    <p>A 2D array with elements {{1234,56},{1256,43},{1434,32},{1312,96}}</p> Signup and view all the answers

    In C++, what is the correct syntax to access an element at the third row and second column in a 2D array 'arr'?

    <p>arr[2][1]</p> Signup and view all the answers

    What does 'c' represent in the declaration 'datatype array_name[r][c];' for a C++ 2D array?

    <p>Number of columns in the matrix</p> Signup and view all the answers

    More Like This

    C Arrays: Understanding and Usage
    5 questions
    Computer Programming 2: Arrays
    12 questions
    Data Structures and Arrays Quiz
    18 questions
    Use Quizgecko on...
    Browser
    Browser