A Little Sum Thing

Test your C++ programming skills by solving the given puzzle about integer type conversions and arithmetic behavior.

Puzzle code

Carefully read the code given below:

Press + to interact
#include <iostream>
#include <numeric>
#include <vector>
int main()
{
std::vector<int> v{-2, -3};
std::cout << std::accumulate(v.cbegin(), v.cend(), v.size());
}

Your task: Guess the output

Try to guess the output of the above code. Attempt the following quiz to assess your understanding.

Q

What is the expected output of the above code?

A)

-3

B)

65533

C)

4294967293

D)

18446744073709551613

Let’s discuss this code and output together in the next lesson.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.