passing a 2d array cpp

#include <iostream>
#include <vector>
using namespace std;

typedef vector< vector<int> > Matrix;

void print(Matrix& m)
{
   int M=m.size();
   int N=m[0].size();
   for(int i=0; i<M; i++) {
      for(int j=0; j<N; j++)
         cout << m[i][j] << " ";
      cout << endl;
   }
   cout << endl;
}


int main()
{
    Matrix m = { {1,2,3,4},
                 {5,6,7,8},
                 {9,1,2,3} };
    print(m);

    //To initialize a 3 x 4 matrix with 0:
    Matrix n( 3,vector<int>(4,0));
    print(n);
    return 0;
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to pass 2d array to a function c++ passing and returning a 2d array in cpp passing a 2d array as an argument in cpp 2d array argument c++ how to pass 2 dimensional array in c++ what is the correct way to pass 2d array to a function in cpp what is the correct way to pass 2d array to a function ibn cpp c++ send 2d array passing 2d arrays in c++ 2d array as a parameter in c++ pass by refence 2d array c++ how to pass a 2d arraya in c++ how to pass 2d array into functions cpp Pass a two dimensional array in C++ pass 2 dimensional array in c++ function c++ send 2d array as parameter to function c++ pass a 2d array to function c++ 2d array parameter how to pass 2d array in function c++\ c++ how to pass 2d array to function 2d array in argument in c++ how to pass a 2d array to function in c++ passing 2-dimensional arrays as parameters c++ pass 2d array in a fucntion c++ pass 2d arrays to a function c++ 2d array passing c++ passing 2d array to functions in c++ pass 2d array as parameter c++ how to pass a 2d arry to a fuction in c++ 2d array pass to function c++ c++ pass 2 dimensional array to function how to pass 2d array in function inc++ passing 2d array by refernce to function in c++ how to pass 2d int array in function in cpp how to use 2D array as parameter in c++ how to pass 2d array in function in cpp how to take 2d array in function argument c++ Passing a 2D array to a C++ function c++ 2d array function parameter 2d array as argument in c++ pass 2d arrays as parameter in c++ two dimensionala array in cpp as a parameter how to pass 2d array to functin in cpp passing 2d array to a function in cpp passing 2d array in c++ function how to pass 2d array to function in cpp how to pass 2d matrix in function in c++ how to pass 2d array as argument in cpp how to pass 2d matrix as argument in cpp c++ pass dynamic 2d array to function pass 2d array in function in c++ c++ 2d array as argument 2d array as parameter in c++ pass 2d array as parameter in c++ passing an 2d array to a funtion c++ pass 2d array in c++ how to send 2d array to a funciton in c++ 2d array c++ argument pass 2d array c++ passing two dimensional array c++ passing 2d array c++ passing 2d array to function c++ example c++ pass 2d array to functioun how to send 2d array in function c++ 2d array passing to function in c++ passing a 2d array as function in c++ c++ pass 2d array by value c++ pass 2 2d array to function c++ pass reference to 2d array passing 2d array to function in cpp 2d array parameter c++ 2d array passing as an argument c++ c++ pass in 2d array as paramete how to pass an 2d array to a function c++ how to pass 2d array as parameter in c++ pass 2d array cpp sending 2d array to function in cpp passing an 2d array in cpp how to pass a 2d array as a parameter in c++ how to pass 2d array to a function in c++ how to pass a 2d array to a function inn cpp how to pass 2d arrays to functions in c++ c++ pass 2d array to function how to take 2d array as function parameter c++ how to pass 2d array in function in c++ c++ 2d array as parameter how to pass 2d array to a fucntion c++ how to pass 2d array to afucntion c++ passing 2d array to a function in c++ how to pass 2d array in a function in c++ pass 2d array in function c++ how to pass 2d array in cpp 2d array as parameter c++ pass a 2d array to a function c++ c++ how to pass 2 2d array to a function c++ how to pass a 2d array to a function passing 2D array in a function in C++ c++ pass in 2d array how to pass a 2d array in c++ how to pass 2d array in c++ how to send 2d array to func cpp passing 2d array in c++ passing a 2d array to a function c++ 2d array c++ as parameter how to pass 2d array in a function c++ passing 2d array as parameter c++ how to pass 2 d dimensional array in c++ passing 2d array'to function c++ how to pass a 2d array to a function c++ how to pass 2d array to function c++ passing 2d array to function in c++ passing 2d array to function c++ how to pass a 2d array in a function in c++ passing 2d array in function c++ passing pointer to 2d array as an argument to a funciton in c++ function input for 2d array in c++ input two dimensional array in c function parameter how to accept a double array in a fgucntion can we pass a 2d array to a function 2d array input to function c++ pass 2d array as reference in function c++ 2d array function c++ calling a function on 2d arrat in c functions of 2d arrays how to do we pass 2d array in function in c++ how to accept a 2d array in a function c++ c++ pass double array to function how to pass multidimensional array in function in c how to pass array2d in function c++ 2 d array as argument to a function c++ passing 2d array to function in c++ by reference pass matrix as argument c++ parameter 2d array c++ pass 2d matrix in c++ passing matrix in cpp c void 2d array pass a 2d array by reference c++ how to pass 2d array as reference in c++ how to get a 2d array into parameter of method can we pass matrix as argumnet 2d array as argument to function c++ pass 2d aray by reference pass 2d array reference c++ C two dimensional array function parameter 2 dimensional array c function passing 2d array in c pass 2d matrix to function in c++ pass 2d array cpp to function pass pointer of 2d arr sending address of double array to a function pass 2d array in function param in c++ how to send 2 dimensional array in function in cpp pass 2d array to function c++ how to pass 2d array to function in c++ 2d array as arg of function in c++ how to pass a 2d array by reference in c++ cpp FunctionCallback multi-dimensional array passing static 2d array a parameter is not allowed passing matrix as argument c++ how to send a 2d array to a function in c++ how to pass multi dimensional array in c++ function matrix as function argument in cpp how to send a dobule array to function cpp how to pass 2d array in function c++ passing 2d array to function inc passing matrix in fucntion cpp pass by reference 2d array c++ 2 dimensional array as argument in function c how to send 2d array to a function in c++ c++ pass multidimensional array as function parameter how to pass a matrix to a function in c++ What is correct syntax to pass two-dimensional array of integer to a function with pointers? void function with two dimensional array in c 2d array passing in function c++ how to pass two dimensional matrix as an argument to function passing 2d array into function c++ how to pass 2d array by reference in c++ 2d array c++ function how to pass 2d array in function i c++ how to have 2d array as parameter in c++ how to pass a 2d array three things how to pass a reference to a 2D array in c++ take 2d array as argument c++ how to pass 2 dimentonal array to function c++ How to pass a n*m matrix in cpp how to pass in a 2d array in c passing 2d array in c why is first blank c programming pass matrix to function c++ matrix as parameter two dimensional array c++ paas to a function pass a reference of 2d array c++ how to pass 2d array into function c++ how to pass a 2d array to a function in c++ how to pass 2d array as argument in c++ void function for 2d array c++ pass 2d array to a function c++ can we pass a 2d array into a function in c pass 2d array by reference c++ c++ get variables from 2d array passing argument into 2 d array in C functions with 2d arrays in c how to declare a 2d array in a function in c++ c++ 2 dimensional array as parameter
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source