Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following piece of C code #include <stdio.h> int a; void f(int x, i

ID: 3761864 • Letter: C

Question

Consider the following piece of C code

#include <stdio.h>

int a;

void f(int x, int y, int z)

{

      int b;

     

      x = x+1;

      y = y+1;

      b = x+y;

      z = z+1;

      a = b;

}

int main()

{

   int b = 1;

   int c[3] = {0,0,0};

     

   {

      int a = 0;

      f(a,b,c[b]);

   }

   printf("%d ", a);

   printf("%d ", b);

   printf("%d ", c[0]);

   printf("%d ", c[1]);

   printf("%d ", c[2]);

   return 0;

}

What is the output of this program if parameters are passed by value?

What is the output of this program if parameters are passed by reference?

What is the output of this program if parameters are passed by name?

Explanation / Answer

a) By value

1

1

0

0

0

b) By reference

3

2

0

1

0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote