Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bubble Sort Algorithm #64

Open
satwikdevle opened this issue Oct 17, 2022 · 2 comments
Open

Bubble Sort Algorithm #64

satwikdevle opened this issue Oct 17, 2022 · 2 comments

Comments

@satwikdevle
Copy link
Contributor

Adding Bubble Sort.cpp

@haideralicodes
Copy link

haideralicodes commented Oct 19, 2022

This is the code for Bubble Sort:
Please merge this pull request that I made to solve the issue. And consider this answer as the 1st comment.

`#include

using namespace std;

int main()
{

int arr[] = {5,1,3,6,4,2};
int a;


//loop for BUBBLE SORT
for(int i = 0; i < 6; i++)
{
    for(int j = i+1; j < 6; j++)
    {
        if(arr[i] > arr[j])
        {
            a = arr[j]; //a = 1
            arr[j] = arr[i]; //arr[1] = arr[0] = 5
            arr[i] = a; //arr[0] = 1
        }
    }
}


//for priting array
for(int j = 0; j < 6; j++)
{
    cout<<arr[j]<<" ";    
}

return 0;

}`

@RiyaSaini1108
Copy link

Please assign this issue to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants