cpp vector2

  1. Declare the vector: Initialize a vector named "vec" with data type int.
  2. Add elements to the vector: Use the push_back() method to add elements 5, 10, and 15 to the vector.
  3. Access elements by index: Retrieve and print the first element of the vector using vec[0].
  4. Iterate through the vector: Use a for loop to iterate through the elements of the vector and print each element.
  5. Remove elements from the vector: Use the pop_back() method to remove the last element from the vector.
  6. Check if the vector is empty: Use the empty() method to check if the vector is empty and print the result.