Answer to Question #280516 in C++ for Toshiki

Question #280516

Write a program that accepts five numbers from the user and displays the values from lowest to highest. Assume that there are no duplicate values.

1
Expert's answer
2021-12-16T14:31:12-0500
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int arr[5];
  for (int i = 0; i < 5; i++) {
    cin >> arr[i];
  }
  sort(arr, arr+5);
  for (int i = 0; i < 5; i++) {
    cout << arr[i] << ' ';
  }

  return 0;
}

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