c++
-
#include <vector> #include <algorithm> using namespace std; int main() { vector<int> data(5,1); int sum {0}; cout << sum << endl; for(auto element : data) sum += element; cout << sum << endl; for(auto p = ++data.begin(); p != --data.end(); ++p) sum += *p; cout << sum << endl; sum = 0; data.push_back(2); data.push_back(3); for(auto element : data) sum += element; cout << sum << endl; cout << accumulate(data.begin(), data.end(), data[0]) << endl; }
MY question is :
- What does the first line of the following print?
- What does the Second line of the following print?
- What does the Third line of the following print?
- What does the Fourth line of the following print?
- What does the fifth line of the following print?
-
Hey @Raghav-Khemka
I am confused. Have you tried running it? Are you asking what the output would be if you ran it?