Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q4 Memory Model 5 Points Consider the following code: #define Foo 5 int TEN10 int bar(int x) return xx int main int int baz malloc(sizeof
Q4 Memory Model 5 Points Consider the following code: #define Foo 5 int TEN10 int bar(int x) return xx int main int int baz malloc(sizeof (int) 20) if (baz) free(baz); bar (FOO) snapshot just before it returns return 0 argc, char *argv[]) For each of the following symbols, choose what section of memory it would live in. a) bar O stack O heap O static O code b) baz O stack O heap O static O code baz O stack O heap O static O code d) TEN O stack O heap O static O code e) x O stack O heap O static O code X Incorrect Submit Last submitted on Feb 13 at 8:57 PM Q5 Strings 7 Points Consider the following code on a 32-bit system #include int main char *a "hello"; int len; // set len to a's length Q5.1 sizeof 1 Point What would the value of sizeof (a) be? Hint: Look at https://en.wikipedia.org/wiki/Sizeof Enter your answer here Submit Q5.2 1 Point Which of the following expressions could we add above to properly compute the length of a? (By convention, we don't include the null-byte in the length of the string.) len a.length lensizeof (a) len strlen (a) = len = 0; while (++*a) { len++; } len0; while (++*a) len;) len-0; while (*a+) len+ti ) len = 0; while (*a++) { ++ len; } Submit Q5.3 1 Point Assume we have the correct string length expression(s) from above, what would be the computed length of the following strings? If this program would cause a compile-time error or the behavior is uncertain, enter "n/a". Code: char a"foobar" Enter your answer here Submit Q5.4 1 Point Code: char a- '' Enter your answer here Submit Q5.5 1 Point Code: char at-f'',, o', 'a', r0 Enter your answer here Submit Q5.6 1 Point Code: char al-', ob',"a', "r'; Enter your answer here Submit Q5.7 1 Point Code char *a-"foo\ Obar"; Enter your answer here Submit
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