Answer to Question #259864 in C++ for ahmed

Question #259864

Write a function to sort an array consists

of 10 integer numbers in descending order,

print the array before sorting and after

sorting.


1
Expert's answer
2021-11-01T18:48:29-0400
#include <bits/stdc++.h>


using namespace std;


int main()
{
  int arr[10] = {3,2,4,5,6,7,2,0,8,4};
  
  cout << "Before reversing the array:\n";
  for (int i = 0; i < 10; i++) {
    cout << arr[i] << ' ';
  }
  
  cout << '\n';
  cout << "Agter reversing the array:\n";
  
  sort(arr, arr+10);
  reverse(arr, arr+10);
  
  for (int i = 0; i < 10; i++) {
    cout << arr[i] << ' ';
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS