Friend Functions in C++:- It is a type of a function which has the permission to access the private and protected members of a class in which this function is ...
Static variables in C++:- These are the type of data members which are declared with the static keyword in the class. They are basically the part of a class ...
In this article we will review the classes and objects in C++ with real world and theoretical examples. Classes in C++:- In object oriented programming, ...
In this article we will review types of Constructors in C++, types of copy constructors and difference between shallow and deep copy. Constructors in C++:- ...
Operator overloading in C++ is a process in which we define the different implementations or working of an operator. This process enables the operator to ...
we will see the working and operations of bubble sort in C++ with proper examples by the sorting of arrays. Sorting of Arrays:- The process of arranging ...
In C++ Two Dimensional array in C++ is an array that consists of more than one rows and more than one column. In 2-D array each element is refer by two ...
Binary Search:- The flaw of a binary search is that it could only be applied on a sorted array. We cannot apply it on an unsorted array. This is a very useful ...
A Functions in C++ is known as the block which contains a set of statements, which are executed when it is called in a Main method. In C++ they are defined by ...
Arrays in C++:- In C++ programming, Arrays are the collection of the consecutive memory locations with same name and similar address in a free store or heap. ...
What are Strings:- The collection of the characters is called string. For Example:- 1. “London”. 2. “Austria”. 3. “Football”. 4. “Stadium “. ...
We can pass Arrays to the Functions as parameters. When we pass parameter to the calling function then only the address of first index of the array is passed. ...
just write if(array[j] lesser then array[j+1]) instead of if(array[j] greater then array[j+1]) and it will sort the array in descending order.
I have updated my comment with a code block containing while loop, cheers.
Okay, that’s the code of Bubble sort by using While Loop written in C++.
while(i < 4) { int j = 0; while(j < 4) { if(array[j]>array[j+1])
{
hold=array[j];
array[j]=array[j+1];
array[j+1]=hold;
}
j++;
}
i++;
}
If you have any other questions then let me know, thanks.
yes we can use a while loop.
Welcome
thanks for pointing out.
my pleasure :)
thanks for pointing out !!!