Menu

[Solved]Include Int Temp 0 Int Sum Int Int M Int N Int Ai M N Temp Temp Ai Return Temp Int Main In Q37283728

#include <stdio.h>

int temp = 0;

int sum(int i, int m, int n, int ai)
{
   for (i = m; i < n; i++) {
       temp = temp + ai;
   }
   return temp;
}

int main()
{
   int a[9] = (1,10,10,10,100,100,100,100,100);
   int b[4][4] ={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};

   int temp = 4;
   int m = 0;
   int n = 3;
   int i = 1;
   int j = 1;
   int result;

   result = sum(i, m, n, i);
   printf(“%d %dn”, temp, result);
   for (int i = 0; i < 9; i++)
       printf(“%d “, a[i]);
   printf(“%dn”, a[i]);

   result = sum(i, m, n, a[i]);
   printf(“%d %dn”, temp, result);
   for (int i = 0; i < 9; i++)
       printf(“%d “, a[i]);
   printf(“%dn”, a[i]);

   n = 2;
   result = sum(i, m, n, sum(j, m, n, b[i][j]));
   printf(“%d %dn”, temp, result);
   for (int i = 0; i < 3; i++)
       printf(“%d “, a[i]);
   printf(“%dn”, a[i]);

1.What is the output of the program if functions are called byvalue?
2. What is the output of the program if functions are called byreference? For this part do not execute lines //1 through //5
3. What is the output of the program if functions are called byname?

Expert Answer


Answer to #include int temp = 0; int sum(int i, int m, int n, int ai) { for (i = m; i < n; i++) { temp = temp + ai; } return temp;... . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *