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
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