-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.cpp
More file actions
64 lines (54 loc) · 1.11 KB
/
array.cpp
File metadata and controls
64 lines (54 loc) · 1.11 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
/****************************************
James Bertel
CS111
Lab 6-1
10-25-17
****************************************/
#include <iostream>
using namespace std;
void fillArray(int ar[]);
void printArray(const int ar[]);
const int SIZE = 5;
int main()
{
int ar[SIZE];
int choice;
do
{
cout << "=============" << endl;
cout << "1: fill the array" << endl;
cout << "2: print the array" << endl;
cout << "9: quit" << endl;
cout << "=============" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch(choice)
{
case 1: fillArray(ar);
break;
case 2: printArray(ar);
break;
case 9: cout << "\nThank you for using our system.\n";
break;
default: cout << endl << "invalid choice\n" << endl;
}
}while(choice !=9);
return 0;
}
void fillArray(int ar[])
{
cout << endl;
for(int i = 0; i < SIZE; i++)
{
cout << "Enter a number: ";
cin >> ar[i];
}
cout << endl;
}
void printArray(const int ar[])
{
cout << "\nThe numbers in the array are ";
for(int i = 0; i < SIZE; i++)
cout << ar[i] << " ";
cout << endl << endl;
}