User Posts: royal52
0
Friend Functions and Friend Classes in C++ with Examples
0

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 ...

0
Static Variables and Static Functions in C++ with Examples
3

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 ...

0
Classes and objects in C++ with Examples
1

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, ...

0
Constructors and Destructors in C++ with Examples
3

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++:- ...

0
Operator Overloading in C++ with examples
0

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 ...

0
Bubble Sort in C++ with examples
5

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 ...

4
Two Dimensional Arrays in C++ with examples
19

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 ...

0
Binary Search in C++ with examples
3

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 ...

0
Functions in C++ with examples
1

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 ...

0
Arrays in C++ with examples
2

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. ...

0
Array of Strings in C++ with examples
2

What are Strings:- The collection of the characters is called string. For Example:- 1. “London”. 2. “Austria”. 3. “Football”. 4. “Stadium “. ...

0
Functions and Arrays in C++ with examples
2

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. ...

Browsing All Comments By: royal52
  1. 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.

  2. I have updated my comment with a code block containing while loop, cheers.

  3. 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.

  4. yes we can use a while loop.

  5. thanks for pointing out.

  6. thanks for pointing out !!!

HellGeeks
Logo