Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Vector #Operation #Access #Elements
ADD COMMENT
Topic
Name
4+7 =