I have written this code in dev c++ and it works but when I try to run it in Visual Studio it gives an error like expression must have constant value.
#include <iostream>
using namespace std;
int main() {
int r, c, j;
int matrix[r][c];
cout << "Enter the size of matrix: ";
cin >> j;
for (r = 0; r < j; r++) {
for (c = 0; c < j; c++) {
cout << "matrix" << "[" << r << "]" << "[" << c << "] = ";
cin >> matrix[r][c];
}
}
cout << "\n";
for (int i = 0; i < j; i++) {
for (int k = 0; k < j; k++) {
cout << " "<<matrix[i][k] << " ";
}
cout << "\n";
}
return 0;
}