First, you can't have
int val[row][col];
before row and col have known values. Second, that kind of 2D array initialization is only standard in C.
You would need to manually allocate the array on the heap using the C++ operator new[] (similar to the malloc function in C). However that's not idiomatic C++ and the whole point of the language is to avoid doing that which is why I won't explain how to do it.
The proper C++ way to accomplish what you want is to use an std::vector, which a very powerful wrapper around C style arrays that automatically allocates and de-allocates memory for you (and a lot of other things).
Here's the simplest way to do that:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int row;
cout << "How many rows are there?" << endl;
cin >> row;
int col;
cout << "How many columns are there?" << endl;
cin >> col;
int num;
cout << "Enter values for the matrix: " << endl;
cin >> num;
vector<vector<int>> values(col); //initialize outer vector with col inner vectors
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
values[i].push_back(num);
}
}
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
cout << values[i][j];
}
cout << endl;
}
return 0;
}
Also, I advise you name your variables with more meaning and that you avoid using namespace std.
EDIT: From the way you approach the program, I assume in my answer you are familiar with C. If that's not the case, and you're following a book or tutorial, you should find a better book or tutorial.