1) What is the output of the below program?

/* Programmer: Mark Fienup

Description: This program illustrate the scope of variables. */

#include <stdio.h>

// function prototypes

double DoSomething( int i, double d );

int DoSomethingElse( int i, int j );

int main() {

int i, j;

double d, e;

i = 3;

j = 4;

d = 2.0;

e = 5.0;

printf("Initially: i = %d, j = %d, d = %.1f, e = %.1f\n", i, j, d, e);

e = DoSomething(i, e);

printf("After: i = %d, j = %d, d = %.1f, e = %.1f\n", i, j, d, e);

return 0;

} /* end function main */

double DoSomething( int i, double d ) {

int j;

double e;

j = 10;

e = 8.0;

printf("Point A: i = %d, j = %d, d = %.1f, e = %.1f\n", i, j, d, e);

j = DoSomethingElse(j, i);

printf("Point B: i = %d, j = %d, d = %.1f, e = %.1f\n", i, j, d, e);

return d * i;

} // end DoSomething

int DoSomethingElse( int i, int j ) {

int sum;

sum = i + j * 2;

printf("Point C: i = %d, j = %d\n", i, j);

return sum;

} // end DoSomethingElse

2. Consider the following recursive program to calculate xn, where n is some nonnegative integer.

/* Programmer: Mark Fienup

Description: This program illustrate recursion. */

#include <stdio.h>

// function prototypes

double Power( double x, int n );

int main() {

double value;

value = Power( 2.0, 3);

printf("2.0 raised to the 3rd power is %f\n", value);

return 0;

} /* end function main */

double Power( double x, int n ) {

if (n == 0) {

return 1;

} else if (n == 1) {

return x;

} else {

return x * Power( x, n-1 );

} // end if

} // end Power

Draw the run-time stack for the execution.