We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a3cdf8f commit e6d6c2fCopy full SHA for e6d6c2f
topfive.cpp
@@ -0,0 +1,27 @@
1
+// topfive.cpp -- handling an array of string objects
2
+#include <iostream>
3
+#include <string>
4
+using namespace std;
5
+const int SIZE = 5;
6
+void display(const string sa[], int n);
7
+int main()
8
+{
9
+ string list[SIZE];
10
+ cout << "Enter your " << SIZE << " favority astronomical sights:\n";
11
+ for (int i = 0; i < SIZE; i++) {
12
+ cout << i + 1 << ": ";
13
+ getline(cin, list[i]);
14
+ }
15
+
16
+ cout << "Your list:\n";
17
+ display(list, SIZE);
18
19
+ return 0;
20
+}
21
22
+void display(const string sa[], int n)
23
24
+ for (int i = 0; i < n; i++) {
25
+ cout << i + 1 << ": " << sa[i] << endl;
26
27
0 commit comments