Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MAXELS = 5;
- int findMax(int [MAXELS]); // function prototype
- int main()
- {
- int nums[MAXELS] = {2, 18, 1, 27, 16};
- cout << "The maximum value is " << findMax (nums) << endl;
- return 0;
- }
- // find the maximum value
- int findMax(int vals[MAXELS])
- {
- int i, max = vals[0];
- for (i = 1; 1 < MAXELS; i++)
- if (max < vals[i])
- max = vals[i];
- return max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement