What will be the output of the following C++ code? [code] #include <iostream> #include <vector> using namespace std; int main() {

Ngoc Hue

New member
What will be the output of the following C++ code?
Code:
#include <iostream> 
#include <vector> 
using namespace std; 
int main() 
{ 
    vector<int> v; 
    for (int i = 1; i <= 5; i++) 
        v.push_back(i); 
    vector<int> :: iterator i;
    i = v.begin();
    *i = 3;
   	for (i = v.begin(); i != v.end(); ++i) 
        cout << *i << " ";
    cout<<endl;
    return 0; 
}
A. 1 2 3 4 5
B. 3 2 3 4 5
C. 5 4 3 2 1
D. 3 3 3 3 3
 

Tìm kiếm

Back
Top