Sunday, December 20, 2015

Addition of vector element

#include <iostream>
#include <vector>
using namespace std;
main()
{   int s=0;
vector<int> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
vector <int>::iterator it;
for(it = v.begin(); it != v.end();++it)
s=s+*it;
        cout <<s;
        return 0;
}

No comments:

Post a Comment