MaxVal - max = maxi( score, NUM_ITEMS ); cout...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Using arrays as arguments in a function call // pass the number of array elements used as an argument // Author: Charles Swanson #include<iostream> using namespace std; int maxi( const int [], int ); // prototype int main() { const int NUM_ITEMS = 5; int max, score[NUM_ITEMS] = {22, 77, 44, 11, 33 };
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: max = maxi( score, NUM_ITEMS ); cout &lt;&lt; &quot;The maximum number is &quot; &lt;&lt; max &lt;&lt; endl; return 0; } int maxi( const int results, int NUM_ITEMS ) { int i, max = results[0]; for( i = 1; i &lt; NUM_ITEMS; i++) { if( max &lt; results[i] ) max = results[i]; } return max; }...
View Full Document

This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online