Facebook
Banner
XMPP JavaScript Library READ MORE

Bubble Sort


1 #include <stdio.h>
2 int main(){
3 int nums[5]={5,4,3,2,1};
4 int temp=0;
5 int n=4;
6
7 for(int k=0; k<n; k++){
8 for(int i=0; i<n-k; i++){
9 if(nums[i]>nums[i+1]){
10 temp=nums[i];
11 nums[i]=nums[i+1];
12 nums[i+1]=temp;
13 }
14 }
15 }
16
17 for(int i=0; i<5; i++){
18 printf("%d",nums[i]);
19 }
20 return 1;
21 }
Add Your Comment
   
    Yes! I want to receive all comments by email

No Comments Posted Yet. Be the first one to post comment