logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/cs256su21code/jul21/testSort.c

/*

A demonstration of BubbleSort

This is the simplest sorting algorithm, it works by repeatedly swapping
adjacent elements if they are in the wrong order.

*/

#include <stdio.h>
#include "sorts.h"

void printArray(int arr[], int size);

int main(){

	int arr[] = { 5, 1, 3, 7, 9, 4, 6, 2, 8}; //declaring a test array

	printf("Before Sort:\n");
	printArray(arr, 9);

	quickSort(arr, 0, 9);

	printf("After Sort:\n");
	printArray(arr, 9);

	return 0;
}



void printArray(int arr[], int size){

	for(int i = 0; i < size; i++){
		printf("%d ", arr[i]);
	}
	printf("\n");

}