#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 ];
       cout endl;  
      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 >> arra[ j ];  
	   return 0;

i want to have a multiplication table after this commands...how can i?? ove try it all

Edited by exekiel101: n/a

6 Years
Discussion Span
Last Post by Duki

You are trying to use dynamic memory to create a multidimensional array (in this case 2 dimensional) but you have the syntax a bit off. Since you've asked for the number of rows, you should probably use them.

int ** table;  //table is a pointer to pointer that will be given memory based on user input
int rows = //whatever
int cols = //whatever, too

//assign memory to table using dynamic memory 
table = new int*[rows];//table is now acts like an array of pointers to type int
for(int i = 0; i < cols; ++i)
  table[i] = new int[cols]; //each pointer to type int now acts like an array of type int, and table acts like a 2 dimensional arry of type int

Now you need to fill the array and do something with it.


I practically gave you the answer to this problem already (without the use of pointers and dynamic memory). Does your assignment require that you use pointers?

Edited by Duki: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.