shivaylamba / Hacktoberfest

Make your first PR! ~ A beginner friendly repository made specifically for open source beginners. Add any program under any language (it can be anything from a hello-world program to a complex data structure algorithm) or update the existing one. Just make sure you add the program under the correct language directory. Happy coding
258 stars 1.88k forks source link

Create BubbleSort.cpp #2287

Open AnuragITrmlau opened 8 months ago

AnuragITrmlau commented 8 months ago

This C++ program uses the bubble sort algorithm to sort an array of integers. The function bubbleSort takes an array and its length as parameters. It iterates through the array multiple times, comparing each pair of adjacent elements and swapping them if they are in the wrong order. This process continues until the array is sorted.

The function printArray is used to print the array elements.

In the main function, an array of integers is initialized, and its length is calculated. The bubbleSort function is then called to sort the array, and the sorted array is printed using the printArray function.

The Following Output for the code will be :

Sorted array: 11 12 22 25 34 64 90

Pull Request

Related issue

Fixes #

What does this PR do?

PR checklist

Please check if your PR fulfills the following requirements:

Thank you so much for contributing to Meilisearch!