Write a program that ask the users to enter three characters. Then the program should display the
following menu
1. Sort in Ascending order
2. Sort in Descending order
The program should perform sorting of these three characters in ascending or descending order as per the user requirement.
#include <bits/stdc++.h>
using namespace std;
int arr[3];
int main()
{
cout << "Input three numbers: ";
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr+3);
cout << arr[0] << arr[1] << arr[2];
cout << endl;
reverse(arr, arr+3);
cout << arr[0] << arr[1] << arr[2];
}
Comments
Leave a comment