Skip to content

Instantly share code, notes, and snippets.

@akerenyi
Created February 2, 2015 11:52
Show Gist options
  • Save akerenyi/57b9174b42d45c89a0e5 to your computer and use it in GitHub Desktop.
Save akerenyi/57b9174b42d45c89a0e5 to your computer and use it in GitHub Desktop.
Bubble sort in C
#include <stdio.h>
#define SIZE 10
int main() {
// helper variables
int outer, inner, temp;
// array with SIZE
int numbers[SIZE];
// Bubble sort
for(outer=0;outer<SIZE;outer++)
for(inner=outer+1;inner<SIZE;inner++)
{
if( numbers[outer] > numbers[inner])
{
temp = numbers[inner];
numbers[inner] = numbers[outer];
numbers[outer] = temp;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment