Explanation For Technical Interview Questions

032. Technical interview question: Give the output of following code

By November 21, 2018 No Comments
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int arr[2][3];
  5. foo(arr);
  6. return 0;
  7. }
  8. void foo(int *arr[])
  9. {
  10. int i = 10, j = 2, k;
  11. arr[0] = &i;
  12. arr[1] = &j;
  13. *arr[0] = 2;
  14. for (k = 0;k < 2; k++)
  15. printf("%d\n", *arr[k]);
  16. }
#include<stdio.h>
int main()
    {
        int arr[2][3];
        foo(arr);
        return 0;
    }
    void foo(int *arr[])
    {
        int i = 10, j = 2, k;
        arr[0] = &i;
        arr[1] = &j;
        *arr[0] = 2;
        for (k = 0;k < 2; k++)
        printf("%d\n", *arr[k]);
    }
Watch all videos like this

Leave a Reply

DEMO01