0% found this document useful (0 votes)
2 views2 pages

expds

The document outlines an experiment to implement bubble sort in the C programming language. It includes a complete code example that defines a bubble sort function and demonstrates its use on an array of integers. The program sorts the array and prints the sorted result.

Uploaded by

princeasthana0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

expds

The document outlines an experiment to implement bubble sort in the C programming language. It includes a complete code example that defines a bubble sort function and demonstrates its use on an array of integers. The program sorts the array and prints the sorted result.

Uploaded by

princeasthana0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No.

09
AIM: To implement bubble sort in C language.

#include <stdio.h>
void bubblesort(int arr[],int n)
{
int i,j;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
{
if(arr[j]>arr[j+1])
{
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
int main() {
int arr[]={10,32,9,26,7,23,12};
int n=sizeof(arr)/sizeof(arr[0]);
bubblesort(arr,n);
printf("Sorted Array:-\n");
for(int i=0;i<n;i++)
{
printf("%d ",arr[i]);
}
return 0;
}

1
2

You might also like