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

Complete the following code with single C statement each: (a) Create a single de

ID: 3807035 • Letter: C

Question

Complete the following code with single C statement each: (a) Create a single declaration of three integer pointers. valsA, valsB, and ptr. (b) In one C statement, allocate an array of 10 uninitialized ints on the heap and assign its address to valsA. (c) In one C statement, allocate an array of 10 ints that are initialized to zero and assign its address to valsB. (d) In one C statement, set the pointer ptr to the address of valsA[6] without using any indexing (i.e., no use of []). ptr = (e) In one C statement, copy the index values of 3, 4, and 5 of valsA to index values of 6. 7 and 8 of valsB.

Explanation / Answer

a) int *valsA,*valsB,*ptr (single declaration of three pointer variables)

b)int valsA[]= malloc(10 *sizeof *valsA)

valsA[9]={}; // with out initialization of array

c)int valsB[]= malloc(10 *sizeof *valsB)

valsB[9]={1,2,3,4,5,6,7,8,9,1};// with initialization of array

d)int valsA[]= malloc(6 *sizeof *valsA) // getting the memory allocation address and for that address variable assigning pointer

valsA[6] = *ptr

e)valsB[i]=valsA[i] // this happens with the ussage of temp variable in swapping