Search
 
SCRIPT & CODE EXAMPLE
 

CPP

2-Dimensional array in c++

int row,col;
cout << "please input how many rows and columns you want accordingly: ";
cin>>row>>col;
//create array in heap.
int **arr=new int*[row];
for(int i=0;i<row;i++)
{
    arr[i]=new int[col];
}
//getting value from user.
for(int i=0;i<row;i++)
{
    for(int j=0;j<col;j++)
    {
        cout<<"Enter a number ";
        cin>>arr[i][j];
    }
}
//display Elements.
    for(int i=0;i<row;i++)
{
    for(int j=0;j<col;j++)
    {
        cout<<arr[i][j]<<" ";
    }
}

return 0;
Comment

C++ Multi-Dimensional Arrays

string letters[2][4] = {
  { "A", "B", "C", "D" },
  { "E", "F", "G", "H" }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: search in vector of pairs c++ 
Cpp :: sort c++ array 
Cpp :: how to convert n space separated integers in c++ 
Cpp :: middle node of linked list 
Cpp :: Basic stack implementation in c++ 
Cpp :: how to parse using stringstream 
Cpp :: template function in class c++ 
Cpp :: array list cpp 
Cpp :: what do we use c++ vectors for 
Cpp :: Arduino Counting 
Cpp :: run with cpp version 
Cpp :: convert c++ to mips assembly code online 
Cpp :: do while loop c++ 
C :: csrf_exempt 
C :: fahrenheit to celsius formula 
C :: allow unrelated histories 
C :: transpose of matrix using c program 
C :: bubble sort a linked list in c 
C :: how to print int in c 
C :: take array as input in c 
C :: execute maven project in cmd 
C :: dart in android studio 
C :: c define array size 
C :: c execute shell command 
C :: vbnet create and write on file 
C :: Counting Sort C 
C :: comment in c language 
C :: fgets remove newline 
C :: How to convert string to int without using library functions in c 
C :: printing out an array in c from user input 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =