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

Using C programming and UNIX/Linux terminal. 3. Suppose a C program contains the

ID: 3901882 • Letter: U

Question

Using C programming and UNIX/Linux terminal.

3. Suppose a C program contains the definition of an array of unsigned short integers. The array is defined as follows: unsigned short us[6] = { 2, 4, 6, 8, 10, 12 }; Suppose that the following C statement printf("%zu %p ", sizeof( unsigned short ), us ); , also in the program, produces 2 0x7fff5d11c866 (a) What would the following subsequent statement print? printf("%p ", &us; [3] ); (b) What would the following subsequent statement print? printf("%p ", &us; [3] + 2); (c) What would the following subsequent statement print? printf("%p ", &us; [3] + us[0] ); (d) Suppose that in this program there is also defined a variable ptr of type unsigned short *. What will be printed as a result of the following subsequent statement combination? ptr = &us; [1] ; printf("%hu ", *++ptr);

Explanation / Answer

So it will print

A) as the address is incremented by 2*3=6 hence it will be 0x7fff5d11c866+6=0x7fff5d11c866c

B)0x7fff5d11c866f

C) the same result as b

D)

This value will be the third element in the us array which is 6

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote