as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
write a c++ program to find the maximum element in an array of numbers.
user
#include <iostream>
using namespace std; 
  
// function to find maximum in arr[] of size n 
int findmax(int arr[], int n) 
{ 
    int max = arr[0]; // initialize maximum 
  
    for (int i = 1; i < n; i++) 
        if (arr[i] > max) 
            max = arr[i]; 
  
    return max; 
} 
 
int main() 
{ 
    int arr[] = {3, 4, 5, 6, 7}; 
    int n = sizeof(arr)/sizeof(arr[0]); 
 
    // function calling 
    cout << "maximum element in the array is " << findmax(arr, n); 
  
    return 0; 
}
assistant