-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathex18.cpp
More file actions
54 lines (44 loc) · 927 Bytes
/
Copy pathex18.cpp
File metadata and controls
54 lines (44 loc) · 927 Bytes
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
/*
CPSC 121-0X
Paul De Palma
depalma
Example 18
*/
//more decisions (which start to get complicated)
#include <iostream>
using namespace std;
int main()
{
unsigned seed;
int a,b,c,d,e;
seed = time(0);
srand(seed);
a = rand();
b = rand();
c = rand();
cout << "using a nested if" << endl;
if (a > b)
if (a > c)
cout << a << " is largest" << endl;
else
cout << c << " is largest" << endl;
else
if (b > c)
cout << b << " is largest" << endl;
else
cout << c << " is largest" << endl;
cout << endl;
cout << "using a compound if" << endl;
//alternatively
if (a > b && a > c)
cout << a << " is largest" << endl;
if (b > a && b > c)
cout << b << " is largest" << endl;
if (c > a && c > b)
cout << c << " is largest" << endl;
cout << endl;
cout << "Here are the integers" << endl;
cout << a << endl;
cout << b << endl;
cout << c << endl;
}