Question: Using Pascal; Implement a sort; bubble, quick or any other sort. The main program must be as follows: BEGIN fillArray (intArray); printArray (intArray); printArray2 (intArray);

Using Pascal;

Implement a sort; bubble, quick or any other sort. The main program must be as follows:

BEGIN

fillArray (intArray);

printArray (intArray);

printArray2 (intArray);

largestValue := findMax (intArray);

WriteLn (The largest value is , largestValue);

sort (intArray);

printArray (intArray);

END. {main}

The sort procedure must implement the following procedure as a nested procedure in the sort procedure. This procedure will switch the value of the two parameters.

PROCEDURE swap (VAR a, b : INTEGER );

Use the following declaration to create a type that then can be used to declare variables, such as intArray used in the main program.

TYPE ArrayType = ARRAY[1..20] OF INTEGER;

The procedures referenced in the main program above must have the procedure headers that work with the code listed above.

The main program listed CANNOT be altered.

printArray and printArray2 will essentially be identical, the only difference will be that printArrays parameter must be of type ARRAY OF INTEGER and printArray2s parameter must be of type ArrayType.

The fillArray procedure should fill the array with random values between 1 and 1000.

DO NOT use literal values in your program, except to create the array type or to set the range for the random values. All code working with the array(s) cannot make any assumptions regarding size.

If there is a function to find the maximum value DO NOT use it. Write a loop to find the largest value.

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