-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprograms.html
More file actions
107 lines (81 loc) · 2.38 KB
/
Copy pathprograms.html
File metadata and controls
107 lines (81 loc) · 2.38 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="app.css"/>
</head>
<body>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="programs.html">Programs</a></li>
<li><a href="info.html">Informations</a></li>
<li><a href="about.html">About Me</a></li>
<li><a href="minecraft.html">Minecraft Server</a></li>
</ul>
<h1>Prorgams</h1>
<h3>This page contains useful programs in C++</h3>
<h3>
Chatper 6 Lab 1
</h3>
<pre>
<code>
#include <iostream>
using namespace std;
int main() {
int numInts;
cin >> numInts;
int userInts[numInts]; // An array to hold the user's input integers
int i;
for (i=0; i<numInts; ++i) {
cin >> userInts[i];
}
for (i=numInts-1; i>=0; --i) {
cout << userInts[i] << " ";
}
cout << endl;
return 0;
}
</code>
</pre>
<h3>
Chatper 6 Lab 2
</h3>
<pre>
<code>
#include <iostream>
#include <iomanip> // For setprecision
using namespace std;
int main() {
double weights[4];
int i;
double sum = 0.0;
double avg = 0.0;
double max = 0.0;
cout << fixed << setprecision(2);
for (i=1; i<6; ++i) {
cout << "Enter weight " << i << ":" << endl;
cin >> weights[i-1];
//cout << weights[i-1] << endl;
}
cout << "You entered: ";
for (i=0; i<5; ++i) {
cout << weights[i] << " ";
}
cout << endl << endl;
for (i=0; i<5; ++i) {
sum = sum + weights[i];
if (weights[i] > max) {
max = weights[i];
}
}
//cout << fixed << setprecision(2);
cout << "Total weight: " << sum << endl;
avg = sum / 5;
cout << "Average weight: " << avg << endl;
cout << "Max weight: " << max << endl;
return 0;
}
</code>
</pre>
</body>
<script src="app.js"></script>
</html>