Code for the implementation not clear

  1. What are the parameters that are there in main?
  2. In line 20, Why is array initialised in this way?
  3. What is the for loop used for? in line 21
  4. in line 25, should it be for(int j=0;j<m;j++)? or j<n?

hi @kamakshi.behl22

  1. These are the parameters used when we want to take input from the command line itself. (bhaiya has compiled the code using the command line here, suppose we wanted to take the values of m, n etc from the command line before the execution of the program started, then these arguments could be used.) argc tells the number of arguments, Its default value is 1, as we have to give the name of the program as an argument too. argv is an array of strings, where each string represents a different argument. We have not used this feature in this program so you can skip this too. You can read more on this topic if you are still confused.
  2. This is the syntax for dynamic array allocation. We have initialised a 1D array in line 20 of size n, and then for each a[i] we have declared another 1D array of size m, hence making a mXn 2D array.
  3. Loop is used for iterating over a in order to make arrays for each row, read above point for clarification.
  4. Yes it should be j < m in line 25.

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.