-
Notifications
You must be signed in to change notification settings - Fork 0
/
stdIn.cpp
66 lines (49 loc) · 1.17 KB
/
stdIn.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This program will ask you to enter ten values, then it will
// determine the largest and smallest
// of the values you entered
#include <iostream>
using namespace std;
const int SIZE = 10;
void getnumbers(double number[SIZE]);
double getLargest(double number[SIZE]);
double getSmallest(double number[SIZE]);
int main()
{
double number[SIZE];
getnumbers(number);
getLargest(number);
getSmallest(number);
return 0;
}
// Gets numbers
void getnumbers(double number[SIZE])
{
for (int count = 0; count < SIZE; count++)
{
cout << "Enter an integer value: ";
cin >> number[count];
cout << "\n";
}
}
// Find Largest
double getLargest(double number[SIZE])
{
double largest;
largest = number[0];
for (int count = 1; count < SIZE; count++)
if (largest < number[count])
largest = number[count];
cout << "The largest value entered is " << largest << endl;
return largest;
}
// Find Smallest
double getSmallest(double number[SIZE])
{
double smallest;
smallest = number[0];
for (int count = 1; count < SIZE; count++)
if (smallest > number[count])
smallest = number[count];
cout << "The smallest value entered is " << smallest << endl;
return smallest;
}