GeeksforGeeks » Interview Questions

Interview Question for Software Engineer/Developer about CPuzzles

(3 posts)

Tags:

  1. gagan
    guest
    Posted 1 year ago #

    void func1(int (*a)[10])
    {
       printf("Ok it works");
    }
    void func2(int a[][10])
    {
       printf("Will this work?");
    }
    main()
    {
       int a[10][10];
       func1(a);
       func2(a);
    }
    

    a) Ok it works
    b) Will this work?
    c) Ok it worksWill this work?
    d) None of the above

  2. Venki
    Moderator
    Posted 1 year ago #

    Both the functions doing same. In later case the two dimensional decays to "pointer to array of 10 integers". Similarly the any multidimensional array can be passed omitting the first dimension. Because the "array" passed to function decays to "pointer". All other dimensions except the first are required to find the element using this pointer.

  3. natasha
    guest
    Posted 1 year ago #

    c


Reply

You must log in to post.

RSS feed for this topic