Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          vectors/vector-0b.cc - C++ preview: Similar program with vectors - variation 1.Lecture 1 - slide 20 : 34
Program 2

#include <iostream>
#include <vector>

int main(){
  std::vector<double> a{1.0, 2.0, 3.0, 4.0, 5.0};
  double sum = 0;

  a[1] = 2.2;

  for(auto el: a){
    std::cout << el << std::endl;
    sum += el;
  }

  std::cout << "Sum = " << sum << std::endl;  // 15.2

  return 0;
}