Please explain these two doubts

Why?

for(int i = 0 ;i <n ; i++)
{
arr[i] = new int[m];
}
is used?
&
What is the role of argv and argc in the main?

to allocate 2D array of size MXN dynamically
first we make array of size M this will store address of n sized m arrays
int **arr=new int * [M]
now we make n sized m arrays

for(int i=0;i<m;i++){
  arr[i]=new int[n];
}

i hope this picture will help you to understand well

Screenshot from 2020-05-03 11-25-10

The variables are named argc (argument count) and argv (argument vector) by convention, but they can be given any valid identifier: int main ( int num_args, char arg_strings) is equally valid. They can also be omitted entirely, yielding int main () , if you do not intend to process command line arguments.

your doubt is very much similar to an another student you can check here also

I think you missed one *.Should this be
int *arr = new int[M]
instead of
int *arr = new int[M]

yes you are right
actually it is int ** arr=new int*[m]

it is error of editor it hide this

i have corrected now

if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course

if your doubt is resolved mark it as resolved from your doubt section inside your course

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.