print matrix

Back to General discussions forum

marvish_Taylor     2024-10-22 12:02:59

include<iostream>

void input(int** stmatrix,int rows,int cols); void print(int** stmatrix,int rows,int cols);

int main() { int rows; int cols;

std::cout << "enter the # of rows :" ;
std::cin >> rows;
std::cout << "enter the # of cols :" ;
std::cin >> cols;
int** stmatrix = new int*[rows];

input(stmatrix,rows,cols);

print(stmatrix,rows,cols);
return 0;

} void input(int** stmatrix,int rows,int cols) { for(int i = 0 ; i < rows ; i++ ) { stmatrix[i] = new int[cols]; for(int j = 0 ; j < cols ; j++ ) { std::cout << "enter R"<<i+1<< "C"<<j<< " : "; std::cin >> stmatrix[i][j]; } } } void print(int** stmatrix,int rows,int cols) { for(int i = 0 ; i < rows ; i++ ) { for(int j = 0 ; j < cols ; j++ ) { std::cout << stmatrix[i][j] << " "; } std::cout << "\n"; } }

Rodion (admin)     2024-10-23 22:08:48
User avatar

Hi Friend!

Regretfully it seems your post doesn't contain any question, suggestion etc. If it is by mistake, just tell, I'll remove it.

Please login and solve 5 problems to be able to post at forum