-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patharray.cpp
More file actions
35 lines (33 loc) · 965 Bytes
/
array.cpp
File metadata and controls
35 lines (33 loc) · 965 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
array<int,5> arr={1,2,3,4,5};
// arr.fill(10); fills the whole array by the number
int size=arr.size();
cout<<"the array is"<<endl;
arr.at(3);
for (int i = 0; i < size; i++)
{
cout<<arr.at(i);
}
cout<<endl;
// cout<<arr.begin();//begin points towards the address of first element of array
//end points towards the address after the last address. Similarly rbegin points towards the address of last element of array
//rends points towards the address before the starting element of array
for (auto it =arr.begin(); it !=arr.end();it++)
{
cout <<*it;//here 'it' is a pointer
}
cout<<endl;
for (auto it :arr)
{
cout<<it;//here 'it' is the value itself
}
cout<<endl;
int start=arr.front();
cout<<start<<endl;
int last=arr.back();
cout<<last<<endl;
return 0;
}