Have you tried anything from your end? If you have stuck anywhere we could have guide you.
I am just trying to help you with your question -
Short Definition: Bubble sort in C is one of the easiest and basic sorting technique that is very easy to implement. In Bubble sorting, we compare two adjacent elements of an array to find which one is greater or lesser and swap them based on the given condition until the final place of the element is not found.
Code Example using For Loop -
#include <stdio.h>
int main(){
int n = 5;
int arr[5] = {44,33,11,22,55};
for(int i=0;i<n-1;i++){
for(int 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;
}
}
}
printf("Array after implementing Bubble sort: ");
for(int i=0;i<n;i++){
printf("%d ",arr[i]);
}
return 0;
}
If you want to learn more or understand the topic in-depth read these resources once:
https://www.scaler.com/topics/c-bubble-sort/
https://en.wikipedia.org/wiki/Bubble_sort