Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include #include int G = 1; int + p; void fune(int - atgl, int arg2) {statie in

ID: 3824429 • Letter: #

Question

#include #include int G = 1; int + p; void fune(int - atgl, int arg2) {statie int S = 10; omt A[10] = {arg^2}; print ("8; %4d, B: %4d, C; %4d ", S, *argl, A[0]); S = arg^2} int main() {int M; P = malloc (10 + size of (int)); M = 100; P [0] = 200; func(&M;, O[0]); fune (P, G): What does the program print? Circle (below) all variables for which memory for the variable itself is allocated at compile time. GPSAM Circle (below) all variables for which memory for the variable itself is allowed on the stack at runtime. GPSAM

Explanation / Answer

1. What does the program print?

Answer:

S: 10, B: 100, C: 200
S: 200, B: 200, C: 1

Program:

#include<stdio.h>
#include<stdlib.h>
int G=1;
int* P;
void func(int* arg1,int arg2) {
static int S=10;
int A[10]= {arg2};
printf("S: %4d, B: %4d, C: %4d ", S, *arg1, A[0]);
S=arg2;
}
int main() {
int M;
P=malloc(10*sizeof(int));
M= 100;
P[0]=200;
func(&M, P[0]);
func(P, G);
}

Output:

S: 10, B: 100, C: 200
S: 200, B: 200, C: 1