#How to make an output of largest number from bubble sort?

13 messages · Page 1 of 1 (latest)

polar barnBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

limpid portal
#

#include <iostream>
using namespace std;
void bubblesort(int a[])
{
    for (int i=0; i<5; i++)
    {
        for (int j=0; j<(5-i-1); j++)
        {
            if (a[j]>a[j+1])
            {
                int temp = a[j];
                a[j]=a[j+1];
                a[j+1]= temp;
            }
        }
    }
}

int main ()
{
    int n [5];
    for (int i=0; i<5; i++) 
    {
        cin>>n[i];
    }
    bubblesort (n);
    for (int i=0; i<5; i++)
    {
        cout <<n[i]<<" ";
    }
    return 0;
}```
polar barnBOT
#

@limpid portal

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. You can use !solved to close a post and mark it as solved.

graceful shaleBOT
#
Program Output
1 2 3 4 7
rose pebble
#

just print the last element of the aray?

vast atlas
#

Hi.

rose pebble
sour marlin
# vast atlas Hi.

what don’t you understand about literally the most basic guidelines for communication on forums like this

sour marlin
sour marlin
rose pebble
#

check their history

sour marlin
#

I mean I kinda don’t need to, this isn’t the first time