Output - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Output

confused0874confused0874 Posts: 2Member
I am needing to find the output of the following code fragment:

vector v (10,5);
v.push_back (3);
cout<<v.front()<<""<<v.back();

Thanks in advance

Comments

  • LundinLundin Posts: 3,711Member
    : I am needing to find the output of the following code fragment:
    :
    : vector v (10,5);
    : v.push_back (3);
    : cout<<v.front()<<""<<v.back();
    :
    : Thanks in advance
    :

    Compile it & run it. It usually does the trick.
  • HK_MP5KPDWHK_MP5KPDW Posts: 770Member ✭✭✭
    : I am needing to find the output of the following code fragment:
    :
    : vector v (10,5);
    : v.push_back (3);
    : cout<<v.front()<<""<<v.back();
    :
    : Thanks in advance
    :

    [blue]You don't have a compiler available to test it out? The constructor creates a [italic]vector[/italic] consisting of 10 instances of the value 5. The push_back statment of course will add the value 3 to the end of the [italic]vector[/italic]. It shouldn't be too hard to figure out what the [italic]front[/italic] and [italic]back[/italic] member functions would return in this case.[/blue]
  • confused0874confused0874 Posts: 2Member
    I don't know anything about programming, so i hoped to have somebody let me know what the output would be. However, I did download visual c++ express and tried to compile it, but I received several syntex errors. Could you recommend what I should use to complile small programs like this?

    Thanks


    : : I am needing to find the output of the following code fragment:
    : :
    : : vector v (10,5);
    : : v.push_back (3);
    : : cout<<v.front()<<""<<v.back();
    : :
    : : Thanks in advance
    : :
    :
    : [blue]You don't have a compiler available to test it out? The constructor creates a [italic]vector[/italic] consisting of 10 instances of the value 5. The push_back statment of course will add the value 3 to the end of the [italic]vector[/italic]. It shouldn't be too hard to figure out what the [italic]front[/italic] and [italic]back[/italic] member functions would return in this case.[/blue]
    :

  • LundinLundin Posts: 3,711Member
    : I don't know anything about programming, so i hoped to have somebody let me know what the output would be. However, I did download visual c++ express and tried to compile it, but I received several syntex errors. Could you recommend what I should use to complile small programs like this?

    The whole source should look like:

    [code]
    #include
    #include
    using namespace std;

    int main()
    {
    vector v (10,5);
    v.push_back (3);
    cout<<v.front()<<""<<v.back();
    return 0;
    }
    [/code]

Sign In or Register to comment.