Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cout << "Number of Elements: ";
- cin >> n;
- int arr[n];
- cout << "Enter " << n << " Elements: ";
- for(int i = 0; i < n; i++)
- cin >> arr[i];
- for(int i = 0; i < n -1; i++)
- for(int j = i + 1; j < n; j++)
- if(arr[i] > arr[j])
- swap(arr[i], arr[j]);
- cout << "Sorted Array: ";
- for(int i = 0; i < n; i++)
- cout << arr[i] << " ";
- cout << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment