Programming II Lab 4 Solution

$35.00 $29.00

Objectives: Learn more about pointers and arrays Description: Modify your functions from the pre-lab 4: createIntArray, getArraySize, and freeArray. In createIntArray function, create an array of integers where 1 ≤ array[i] ≤ 20, using rand function. Store maximum value of the array at “array[-1]”, store the size of the array at “array[-2]”, and store the…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Objectives:

  • Learn more about pointers and arrays

Description:

  • Modify your functions from the pre-lab 4: createIntArray, getArraySize, and freeArray.

  • In createIntArray function, create an array of integers where 1 ≤ array[i] ≤ 20, using rand function.

  • Store maximum value of the array at “array[-1]”, store the size of the array at “array[-2]”, and store the elements starting from “array[0]”.

After updating your createIntArray(), your array should look like below:

array[-2]

array[-1]

array[0]

array[1]

array[2]

array[3]

array[18]

array[19]

Size Max_Value

Main function steps:

  • Call createIntArray function.

  • Call getSizeArray and assign its return value to a variable called size2

  • Print your array, array size, and a maximum integer in the array as shown in Example output below.

  • Free the created array using your freeArray function.

Every user-defined function must have a comment describing:

  • What function does;

  • What parameter values are;

  • What value it returns.

Example output:

Please enter an array size: 8

Array: [ 11 12 15 1 6 9 13 12 ]

My array size from getArraySize() is 8.

Max value: 15

Function Prototypes:

  • int* createIntArray(int arraySize);

  • int getArraySize(int* array);

  • void freeArray(int* array);

Grading Criteria:

Main program:

3 points

createIntArray function:

6 points

getArraySize function:

3 points

freeArray functions:

3 points

1

Section A

Note:

  • If your code does not compile with –Wall and –Werror, you will receive a zero for this assignment.

  • You need to finish at least three peer reviews within three days of this lab. Otherwise, you will get a 20% penalty.

  • You will lose points if you don’t have enough comments.

2

Programming II Lab 4 Solution
$35.00 $29.00