Last Updated : 10 Apr, 2024

What will be the output for the below code snippet:

vector <char> ch = {\'f\', \'o\', \'r\', \'k\', \'c\', \'p\', \'p\'};
reverse(ch.begin() + 3, ch.end());
cout << ch[3]; 

(A) k
(B) p
(C) c
(D) None of the mentioned


Answer: (B)

Explanation:
reverse(first, last): reverse the order of elements in the vector. Now the vector contains {\’f\’, \’o\’, \’r\’, \’p\’, \’p\’, \’c\’, \’k\’}.


Share your thoughts in the comments