i cannot get the logic of this thing...

i will input the number of rows

example "rows=5"

then

"input the numbers = 2 3 8 9 7"

what codes could i use???

You can use this :

int row;
cin >> row;
int *arr = new int[ row ];
for( int i = 0; i < row; i++ )
   cin >> arr[ i ];

But I think I don't understand you .

#include <iostream>
#include <iomanip>
 using namespace std;
 int main() {


  
      int rows;
      cout<< "put the number of rows here"" ";
	  cin >> rows;
     cout<< "numbers here""\n ";
	  int *arr = new int[ rows ];
	  for( int i = 0; i < rows; i++ ){

		  cin >> arr[ i ];
 }   
       
      int col;
     cout<< "put the number of columns here"" ";
      cin >> col;
       cout<< "numbers here""\n "; 
	  int *arra = new int[ col ];
	  for( int j = 0;j < col; j++ ){
       
		   cin >> arr[ i ];  
	  }
	  cout << setw(5) <<  ;
		   return 0;
		}

iwant now this to be like a multiplication table..hehehe

You need to format your code. It is impossible to read.

If this is a multiplication table, why do you want the user to input the cells? Values will be from 0 or 1 to numRows or numCols.

Regardless, you create a dynamic 2-D array like this:

int numRows, numCols;

cin >> numRows;
cin >> numCols;

int** arr = new int*[numRows];
for(int i = 0; i < numRows; i++)
{
    arr[i] = new int[numCols];
}

Now the array is created. Fill in the values however you like.

Edited 6 Years Ago by VernonDozier: n/a

This article has been dead for over six months. Start a new discussion instead.