Question
Problem 1. Consider the following code in C syntax: int b; int temp = 3; int set_b(int i, int a) { i = i +
Problem 1. Consider the following code in C syntax:
int b;
int temp = 3;
int set_b(int i, int a)
{
i = i + 1;
b = a;
}
int p(int x, int y int S[])
{
for (x = 0; x < 3; x++) {
temp = temp + S[y];
S = temp;
}
return temp + b;
}
main()
{
int a[3][3];
int b;
int r;
int temp = 4;
int i = 1;
set_b(i, a[i][i]);
a[0][0] = 100; a[0][1] = 10; a[0][2] = 10;
a[1][0] = 1; a[1][1] = 10; a[1][2] = 100;
a[2][0] = 100; a[2][1] = 100; a[2][2] = 100;
b = 0;
r = p(i, r, a[i]);
printf("%d %d %d %d ", i, temp, b, r);
printf("%d %d %d ", a[0][0], a[0][1], a[0][2]);
printf("%d %d %d ", a[1][0], a[1][1], a[1][2]);
printf("%d %d %d ", a[2][0], a[2][1], a[2][2]);
}
What is the output of the program if parameters are passed by value?
What is the output of the program if parameters are passed by reference?
What is the output of the program if parameters are passed by name?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started