doubt in multiple choice questions in C

Discussion in 'C' started by sudheer157, Sep 6, 2007.

  1. sudheer157

    sudheer157 New Member

    Joined:
    Aug 22, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    please tell me the sol to this Question
    Code:
    int **make_matrix(int *m,int *n,int mlen,int nlen)
    {
    int j,k;
    int **matrix=malloc(mlen*nlen*sizeof(int));
    
    for(k=0;k<nlen;k++)
    for(j=0;j<mlen;j++)
    matrix[k][j]=m[k]*n[j];
    
    return matrix;
    }
    function make_matrix defined above contains a serious error.which of the following describes the error.

    1.C does not allow creation of multidimwntiona arrays.
    2.Tha call to malloc() allocates insufficient space to accommodate the correct number of elements.
    3.Inside make_matrix dereferences random memory address,resulting in undefined behaviour.
    4.C uses row-major indexing rather than column -major indexing.The logic used to compute indices is therefore incorrect.
    5.internal algorithms of make_matrix() consistantly result in memory leak.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,346
    Likes Received:
    382
    Trophy Points:
    83

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice