C Program to Sort an Array in Ascending Order Using Bubble Sort



/*
www.troubleshootyourself.com
C program to sort an Array in Ascending order using Bubble Sort
*/
 
#include 
 
#define MAX 100
 
int main()
{
    int arr[MAX], maxLimit;
    int i,j,temp;
     
    printf("Enter total number of elements to sort: ");
    scanf("%d",&maxLimit);
     
    /* Read elements to sort */
    printf("Enter array elements: \n");
    for(i=0; iarr[j+1])
            {
                temp=arr[j];
                arr[j]=arr[j+1];
                arr[j+1]=temp;
            }
        }
    }
 
    printf("Array elements in Ascending Order:\n");
    for(i=0; i

Check and run the program here:

You can run the above program on codeboard editor and see the results. You are allowed to modify code and run. In the editor there is a menu at the top-right corner. Here you can see two buttons such as ‘Compile’ and ‘Run’.

Share this:
We will be happy to hear your thoughts

Leave a reply

Troubleshootyourself
Logo