Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Implement Bubble Sort Using C

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 101
    Comment on it

    Bubble Sort:- Bubble Sort is the one of most popular Sorting Algorithm that is used to sort the array of n size. The Worst case and Average Case Complexity of Bubble Sort is O(n)^2. The Below Code will show you how to implement the bubble sort to sort the array of n size.

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int size=0, a[100],i,j,temp;
    clrscr();
    printf("Enter the Size of Array:=");
    scanf("%d",&size);
    printf("Enter the Element of Array\n");
    for(i=0;i<size;i++)
    {
        scanf("%d",&a[i]);
    }
        for(i=0;i<size-1;i++)
        {
            for(j=0;j<(size-i)-1;j++)
            {
                if(a[j]>a[j+1])
                {
                    temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
        }
    
        printf("Sorted Array is :\n");
        for(i=0;i<size;i++)
        {
            printf("\n%d",a[i]);
    
        }
    
    
    getch();
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: