Question: Draw the stack at the execution point for below program #include using namespace std; int main(); void print_array( int a[], int s) { // YOUR

Draw the stack at the execution point for below program

#include

using namespace std;

int main();

void print_array(int a[], int s) { // YOUR STACK DRAWING

int i;

for(i=0; i < s; i++) {

printf("%d:%d, ", i, a[i]);

}

printf(" ");

}

/***********************************/

int mystery(int a[], int s, int y){

int i, val;

val = 0;

for(i = 0; i < s; i++) {

if(a[i] > y) {

val++;

a[i] = a[i] - y;

}

}

// DRAW THE STACK WHEN EXECUTION GETS HERE

return val;

}

/*************************************/

int main() {

int i, myarray[10], num;

for(i=0; i < 10; i++) {

myarray[i] = i;

}

printf("Before: ");

print_array(myarray, 10);

num = mystery(myarray, 7, 3);

printf("After: num = %d ", num);

print_array(myarray, 10);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!