Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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: 767Member ✭✭✭
    : 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.