Answers for "C++ Vector Operation Access Elements"

C++
0

C++ Vector Operation Access Elements

#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> num {1, 2, 3, 4, 5};

  cout << "Element at Index 4: " << num.at(4) << endl;
  cout << "Element at Index 3: " << num.at(3) << endl;
  cout << "Element at Index 2: " << num.at(2) << endl;
  cout << "Element at Index 1: " << num.at(1) << endl;
  cout << "Element at Index 0: " << num.at(0);

  return 0;
}
Posted by: Guest on May-05-2022

Code answers related to "C++ Vector Operation Access Elements"

Browse Popular Code Answers by Language