• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Array | Data Structure Quiz for Beginners | Question 24

What will do the below code snippet?

C++
#include <iostream>
using namespace std;

int main()
{
    int m = 3, n = 4, c = 0;

    int* arr = new int[m * n];

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {

            *(arr + i * n + j) = ++c;
        }
    }

    return 0;
}

(A)

It will create a 1d array and assign value to it.

(B)

It will create a 1d array of size m*n and assign value to it.

(C)

It will create a 1d dynamic array and assign value to it.

(D)

It will create a dynamic 2d array and assign value to it.

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments