# 2d array

• 10-23-2003
kuwait
2d array
Hi

How can i define a 2d array without giving the size of it
i want the user to enter the size
please can somone tell me how?

Code:

```#include<stdio.h> int main(){ int arow,acol,brow,bcol,crow,ccol; int i,j,m,k;, int a[arow][acol],b[brow][bcol],c[crow][ccol];  // error occur here printf("Enter the first matrix row and column size\n"); scanf("%d%d",&arow,&acol); printf("Enter the second matrix row and column size\n"); printf("(column size must have the same size of row size of the first matrix)\n"); scanf("%d%d",&brow,&bcol); if(arow!=bcol) printf("Cannot perform the multiplication\n"); else{ crow=arow; ccol=bcol; printf("Enter the first matrix elements\n"); for(i=0;i<arow;i++)   for(j=0;j<acol;j++)     scanf("%d",&a[i][j]); for(i=0;i<brow;i++)   for(j=0;j<bcol;j++)     scanf("%d",&b[i][j]); for(i=0;i<crow;i++)   for(j=0;j<ccol;j++)           for(k=0; k<acol;k++){                 m=a[i][k]*b[k][j];         c[i][j]+=m;} } return 0; }```
• 10-23-2003
```int size1, size2, i; cout << "enter size1; cin >> size1; cout << "enter size2; cin >> size2; int ** twoDarrayOfInts; twoDarrayOfInts = new int[size1]; for(i = 0; i < size1; ++i)   twoDarrayOfInts[i] = new int[size2];```