PLEASE CHECK IF I AM RIGHT Write a program to input 10 integer numbers into an array named fmax and determine the maximum value
/* Given an array arr[] and an integer k, we neex to pring k maximum element of givn array. */ #include <iostream> // #include <unistd.h> using namespace std; void printMax(int arr[], int k, int n) { for(int i=0; i<n; i++) { for(int j=i+1; j<n; j++) { if(arr[i] > arr[j]) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } cout << "Sorted Array: "; for(int i=0; i<n; i++) { cout << arr[i] << " " ;// Sleep(1000); } cout << endl; // find k max elements in array cout << "First " << k << " max elements in array are: "; for(int i=n-1; i>=n-k; i--) { cout << arr[i] << " ";// Sleep(1000); } /* if array is sorted in descending order use this loop - for(int i=0; i<k; i++){ - cout << arr[i] << " "; Sleep(1000); - } */ } int main() { int arr[5] = {85,26,14,96,41}; int n = sizeof(arr) / sizeof(arr[0]); int k = 2; printMax(arr, k, n); return 0; }