{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CProgPart1EXORT2

# CProgPart1EXORT2 - int i k j int temp for(i = 1(i<=...

This preview shows pages 1–2. Sign up to view the full content.

C Language Programming Part 1 EXSORT2 /******************* Homework Assignment 1 Part 1-exsort2 By: /******************/ #include <stdio.h> #define size 10 void swap( int array1[], int i, int j); void sort( int array1[], int array1size); void disarray( int array1[], int array1size); int main() { int array1[size] = {4,10,5,1,6,7,3,9,8,2}; int array1size = size; printf("The original unsorted array:\n\n"); disparray(array1, array1size); printf("\n\n\n"); sort(array1, array1size); printf("The sorted array:\n\n"); disparray(array1, array1size); printf("\n\n"); system ("PAUSE"); return 0; } void sort( int

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int i, k, j ; int temp; for (i = 1; (i <= array1size ) ; i++) { disparray(array1, array1size); printf("\n\n"); for (j = 0; (j < array1size - i); j++) { swap(array1, i, j ); } } } void swap( int array1, int i, int j) { int temp; if (array1[j] > array1[j+1]) { temp = array1[j + 1]; array1[j + 1] = array1[j]; array1[j] = temp; } } void disparray( int array1, int array1size) { int x; for (x = 0; x < array1size; x++) { printf("["); printf("%d", array1[x]); printf("]"); } printf(" "); //spaces between elements }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern