So I am a Beginner in C and I was going through Arrays and i was having success with arrays restricted to bounds of constant integers... But i also wanted to find out what happens if we give in a random number for the Numbers of Rows and columns.. However when i executed the program all was fine until the 4th element wherein Vscode with display an error message of Matrix.exe(The compiled file) not working.. I somehow guessed that the error was with vscode itself..(i might be horribly wrong) So i went for an online compiler and didnt get the desired result..which was received easily with bounded constant integers..
The code is about treating a two dimensional array as a Matrix and then getting the desired result in a table form i.e to get a print of all the elements in a tabular form. I will post the code now:
`
#include<iostream>
using namespace std;
int main()
{
int m,n;
int matrix[m][n];
cout<<"Please give the number of Rows:";
cin>>m;
cout<<"Please give the number of columns:";
cin>>n;
for (int i=0;i<m;++i)
{
for (int j=0;j<n;++j)
{
cout<<"Please enter matrix element:";
cin>>matrix[i][j];
}
}
//printingmatrix
cout<<"The Matrix is:";
for (int a=0;a<m;a++)
{
for (int b=0;b<n;b++)
{
cout<<matrix[a][b]<< " ";
}
cout<<endl;
}
}`
I dont actually know what the problem is the code might be incorrect but seemed logically correct to me... I actually dont have any idea of why i am not receiving the result!
Also this is my first stack ques so sorry if I sucked at asking! ;) Any help will be appreciated! Thanks!