5) Write a program to take 6 elements as input in array and sort them.

#include using namespace std; int main() { int array[6], a[6] ,temp; cout << "Enter the 6 elements in array\n"; for (int i = 0;

Anonymous School

            (Minds of Hacker)

--------------------------------


 Write a program to take 6 elements as input in array and sort them.


C++ Practical



#include <iostream>
using namespace std;
int main()
{
    int array[6], a[6] ,temp;
    cout << "Enter the 6 elements in array\n";
   for (int i = 0i < 6i++)
   {
     cin >> array[i];
        
    }

   for (int i = 0i < 6i++)
   {
        for (int j = 0j <7j++)
        {
        

            if (array[i] <array[j])
            {
                temp=array[i];
                array[i]=array[j];
                array[j]=temp;

            }
            
        }
       
    }

cout<<"\nafter sorting array\n";
    for (int i = 0i < 6i++)
    {
        cout<<" "<<array[i];
    }

}



Output:


Enter the 6 elements in array 2 3 4 23 67 14 after sorting array 2 3 4 14 23 67



 *******************Don't Make Learning Hard*****************



Follow us on :-

1) YouTube Channel :- Click Here

2) Blog                     :- Click Here


NextGen Digital... Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...