Question: : Consider the C program: #include int * f ( int choice, int x ) { int y = x; if ( choice = =

: Consider the C program: #include int* f (int choice, int x){ int y = x; if (choice ==0){ return &x; } else { return &y; }} void main (int argc, char** argv){ int a =5; int b =10; int *p = f (0, a); int *q = f (1, b); printf ("%d
",*p); printf ("%d
",*q); } Consider the following statements: 1. The contents of local variable p is a pointer to a heap-allocated object. 2. The contents of local variable q is a dangling pointer. 3. The calls to printf result in this program having undefined behavior. Identify all of the statements that are true: A : 1 and 3 B : 1 and 2 and 3 C : 2 D : 1 and 2 E : 2 and 3 Question 2: Recall that in C

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 Programming Questions!