cpp print vector

include

include

int main() { std::vector nums = {1, 2, 3, 4, 5};

for (int i = 0; i < nums.size(); i++) {
    std::cout << nums[i] << " ";
}

return 0;

}

Explanation: - The first line includes the necessary libraries for the program to work with vectors and input/output operations. - The main function is the entry point of the program. - In the next line, a vector called "nums" is declared and initialized with 5 integers: 1, 2, 3, 4, and 5. - The for loop iterates from 0 to the size of the vector using the variable "i" as the loop counter. - Inside the loop, the current element of the vector is printed using std::cout. - The "<<" operator is used to concatenate the current element with a space character. - The last line returns 0 to indicate successful execution of the program.