Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double giveMeMaxmum(double theArray[], int size)
- {
- double max = theArray[0];
- for (int i = 1; i < size; i++)
- {
- if (max <= theArray[i])
- {
- max = theArray[i];
- }//endif
- }//endfor
- return max;
- }//end max
- int main()
- {
- const int FIVE = 5;
- double sampleArray[FIVE];
- for (int i = 0; i < FIVE; ++i)
- {
- cout << "Input data for index " << i <<": ";
- cin >> sampleArray[i];
- }//endfor
- double sum = 0;
- double max = sampleArray[0];
- double min = sampleArray[0];
- for (int i = 0; i < FIVE; ++i)
- {
- cout << "data at index " << i << " = " << sampleArray[i] << endl;
- sum = sum + sampleArray[i];
- if (max <= sampleArray[i])
- {
- max = sampleArray[i];
- }
- if (min >= sampleArray[i])
- {
- min = sampleArray[i];
- }
- }//endfor
- cout << "the sum is " << sum << endl;
- cout << "Max is " << max << endl;
- cout << "Min is " << min << endl;
- cout << "the maximum coming from the function is "<< giveMeMaxmum(sampleArray, FIVE) <<endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement