Last active
April 1, 2019 10:41
-
-
Save jatinsharrma/b44cca23b496948a483f231b4e79c146 to your computer and use it in GitHub Desktop.
Sorting a array - Sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int Sort(int array[], int size){ | |
for (int i = 0 ; i< size ;i++){ | |
for (int j = i; j <size; j++){ | |
if (array[j]< array[i]){ | |
int temp = array[i]; | |
array[i] = array[j]; | |
array[j] = temp; | |
} | |
} | |
} | |
for (int i = 0; i<size ; i++){ | |
printf("%d \n",array[i]); | |
} | |
} | |
void main() { | |
int array[] = {9,8,7,6,5,4,3,2,1,0}; | |
int size = sizeof(array)/sizeof(array[0]); | |
Sort(array,size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment