#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

Recommended Answers

All 2 Replies

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.