Easy Programming – Beginner C++ Tutorial – The Bubble Sort (23)

38
59



In this tutorial, I introduce the concept of a Bubble Sort. This code allows you to sort objects/values/variables in your program from largest to smallest or smallest to largest. It’s very simple and it’s the first program before I introduce the Index sort for you which will be a little different.

You will need to know about Arrays, the for loop, and the if statement for this program. If you are not familiar with any of them, please have a look at my other tutorials and familiarize yourself before doing this tutorial.

If you have any questions about the program or anything in general relating to beginner C++ Programming, feel free to ask.

And remember to visit my site to view my other programming tutorials! They are all on the website and it will be updated as soon as new programs are uploaded.

I hope you enjoy the video and if you have any requests feel free to let me know. Thanks for watching and remember to subscribe!

#EasyProgramming #ProgrammingTutorial #BubbleSort

———–
Visit my website:
Subscribe on YouTube:
Support me on Patreon:
Follow me on Twitter:
Like me on Facebook:
Check out my Github:

Nguồn:https://quydinh.com/

38 COMMENTS

  1. noneho weho ntago uri imbata(durk). ntanubwo ibintu byawe ari ubufu(cassava flour). uri umuntu wumusaza(aged above 65) byahatari.

  2. #include<iostream> // bubble sort
    #include<conio.h>
    using namespace std;
    int main()
    {
    int arr[6]={5,4,3,2,1,0};
    for(int i=0; i<6;i++)
    for(int j=0;j<6-1;j++)
    if(arr[j]>arr[j+1])
    {
    int swap=arr[j];
    arr[j]=arr[j+1];
    arr[j+1]=swap;}
    for(int a=0; a<6;a++)
    {
    cout<<arr[a]<<" "<<endl;
    }
    cin.ignore();
    cin.get();
    }
    this is a bubble sort ?????????????????????????????/

  3. for the second for loop, I had to change
    for (j = i + 1; j <= size; j++)
    to
    for (j = i + 1; j < size; j++)

    hopefully this helps someone

  4. I am taking Intro to C++ at a community college. My teacher takes attendance and then leaves right after doing so (it's supposed to be a five hour class). He has taught us nothing at all, yet we still have assignments from the book to do. We are teaching ourselves.

    So here I am on youtube, trying to learn. This is the best video I have seen so far to help me understand this concept of bubble sorting and nested loops. Thank you very much for posting this.

LEAVE A REPLY

Please enter your comment!
Please enter your name here