C examples for Function:Function Parameter
Sorting an Array of Integers into Ascending Order with function using bubble sort
#include <stdio.h> void sort (int a[], int n){ int i, j, temp; for (i = 0; i < n - 1; ++i) for (j = i + 1; j < n; ++j) if (a[i] > a[j]) {/* ww w . j a v a2 s . co m*/ temp = a[i]; a[i] = a[j]; a[j] = temp; } } int main (void) { int i; int array[16] ={ 3, -5, 6, 1, 2, 10, 6, 4, 8, -3, -9, 12, 17, 22, 16, 11 }; void sort (int a[], int n); for (i = 0; i < 16; ++i) printf ("%i ", array[i]); printf ("\n"); sort (array, 16); for (i = 0; i < 16; ++i) printf ("%i ", array[i]); printf ("\n"); return 0; }