repl.it
@basicer/

cpp11

C++11

No description

fork
loading
Files
  • main.cpp
main.cpp
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
#include <iostream>
#include <array>

using namespace std;


int main() {
  std::cout << "STL Sequetial Containers: Array\n";

    //Creating an array container with braced initializer
    int myarray[11] = {9,8,7,6,5,4,3,2,1,0} ;

    array<int,6> ar;// {1, 2, 3, 4, 5, 6}; 

    //Accessing elements with [] operator
    for (int i = 0;i < 6;++i)
        ar[i] = ar[i] * 2;
        
        
    //Accessing elements using the pointer to the underlying array

    for (int i = 0;i < 6;++i)
      cout << ar[i] << ", ";
    cout << endl;

    ar.fill(99);

    for (int i = 0;i < ar.size();++i)
      cout << ar[i] << ", ";
    cout << endl;
    
    cout << ar.size() << endl;
}