Having this vector
vector<int> v{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
how can I compute the sum of the first half of it (which is 15) using the accumulate function?
Can I do this using the for loop with only the iterators (not numerical indexes)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can
if
vis your vector.You can also write a loop: