Anonymous School
(Minds of Hacker)
--------------------------------
Write a program to take 6 elements as input in array and sort them.
#include <iostream>using namespace std;int main(){int array[6], a[6] ,temp;cout << "Enter the 6 elements in array\n";for (int i = 0; i < 6; i++){cin >> array[i];}for (int i = 0; i < 6; i++){for (int j = 0; j <7; j++){if (array[i] <array[j]){temp=array[i];array[i]=array[j];array[j]=temp;}}}cout<<"\nafter sorting array\n";for (int i = 0; i < 6; i++){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