(Solved) : Part 2 Marks Type Following Program Document Every Line Explaining Function Output Line P Q41408228 . . .

Part A. (2 marks) Type the following program and document everyline by explaining its function and output. If any line produces anerror, comment that specific line and explain the nature of theerror. Write your code for this part in a file called: Lab5a.c

#include

int main() {

int a = 7 ;

int *aPtr ; aPtr = &a ; printf( “%p”, &a );

printf( “%p”, aPtr );

printf( “%p”, &aPtr );

printf( “%d”, a );

printf( “%d”, *aPtr );

printf( “%p”, *&aPtr );

printf( “%p”, &*aPtr );

printf( “%d”, *&a );

printf( “%d”, &*a );

return 0;

}

Part B. Array Manipulation with Pointers (6 marks) Write,document and test each of the following function specifications(write your code for this part in a file called: Lab5b.c):

[You should use only pointer arithmetic – DO NOT USE arrayindices (i.e. subscripts)].

1. A function called FillArray() that accepts a pointer to ainteger as the array name, an integer for its size. This functionpseudo-randomly fills the array with integers ranging from 0 to100. Do not be concerned about possible duplicate values.

2. A function called PrintArray() that accepts a pointer to ainteger as the array name, an integer for its size. This functiononly prints the array elements.

3. A function called BubbleSort() that accepts a pointer to ainteger as the array name, an integer for its size. The functionshould sort the array passed, in descending order. Use the functionSwap() that you designed in the last Lab #4, to swap any values inthe function BubbleSort().

4. In the main() function:

a. Declare an integer array called NumList of size SIZE (defineSIZE as 20, using #define).

b. Populate the array with pseudo-random numbers [0 -100] bycalling the function FillArray().

c. Display the Array contents by calling the functionPrintArray().

d. Sort the array NumList in descending order by calling thefunction BubbleSort().

e. Display the SORTED array by calling the functionPrintArray().

For your convenience, the function prototypes are given bellow:-

void FillArray (int *array, int size); –

void PrintArray (int *array, int size); –

void BubbleSort (int *array, int size); –

void Swap (int *x, int *y);

Expert Answer


Answer to Part A. (2 marks) Type the following program and document every line by explaining its function and output. If any line …