How to find the max element in int array with C++

1 Answer

0 votes
#include <iostream>
#include <bits/stdc++.h> 
  
using namespace std;
  
int main() 
{ 
    int arr[] = {9, 1, 31, 12, 13, 3, 89, 100, 233, 4, 144, 99}; 
    int len = sizeof(arr) / sizeof(arr[0]); 
      
    int max = *max_element(arr, arr + len); 
    
    cout << max;
      
    return 0; 
} 
  
  
  
/*
run:
  
233
  
*/

 



answered May 23, 2019 by avibootz
...