Final Examm January 1, 2018 GEEN 2312 6) Show the output of the following program. You must trace the code to show how you reached the answer. (5 points) #include int y 5; int z = e; void my_first function) void my_second function) int main) int y y=x; if (z) my first.function): my_second_function); else X++5 y4+; if (z) my_first function); my_second_function(); else return 0; void my_first function) ( printf(“The value of xey in my_first_function() is xdn”, x+y); void my_second_function) f z = 1; printf(“The value of in my-second-function() is %dn”, x); x

Program:
int x = 10; // global value of x is 10
int y = 5; // global value of y is 5
int z = 0; // global value of z is 0
void my_first_function();
void my_second_function();
int main ()
{
int y;
y = x; // y value is 10
Take the global value of z because no local value for z.
if(0) // it if statement is false
else
my_second_function(); // calling function
Now control transfer to called function
void my_second_function ()
{
x=100; // The local value of x is 100
z=1; // Now z value become 1
printf(“The values of x in my_second_function() is %dn”, x);
// It print The values of x in my_second_function() is 100
}
Control transfer to next statement in main
x++; // 100+1 = 101
y++; // 10+1 = 11
Since z value is changed to 1 in void my_second_function ()
if(1) // It means if statement is true
my_first_function(); // calling function
Now control transfer to called function
void my_first_function()
{
printf(“The values of x + y in my_first_function() is %dn”, x+y);
// Here y value is taken from global value because the y value is not changed in the my_second_function() so x+y = 101 + 5 =106 it print The values of x + y in my_first_function() is 106
}
Output:
The values of x in my_second_function() is 100
The values of x + y in my_first_function() is 106
 
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

What Students Are Saying About Us

.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐
"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"

.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."

"Order a Custom Paper on Similar Assignment! No Plagiarism! Enjoy 20% Discount"