-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFill-array.cpp
More file actions
44 lines (34 loc) · 915 Bytes
/
Fill-array.cpp
File metadata and controls
44 lines (34 loc) · 915 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
//CSC 160 Homework 1 Due 4/15/16
//Purpose: Write program for array of integers including various
// criteria (second array)
//Author: Larsen J Close Most recent changes: 4/15/16
#include <iostream> // preprocessor directive
#include <iomanip> // needed for most manipulators
using namespace std; // using directive
void unitFill( int n[], int m)
{
for(int x=0; x<m; x++)
{
n[x] = 1;
}
}
int main ( void )
{
int y[5];
unitFill(y, 5); //fill the y array with unit values (ones)
cout << " k y[k]\n";
for(int k=0; k<5; k++){
cout << setw(3) << k << setw(5) << y[k] << endl;
}
system("pause");
return 0;
} //end main ( )
/* Display of above program
k y[k]
0 1
1 1
2 1
3 1
4 1
Press any key to continue . . .
*/