C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Output Posted by confused0874 on 8 Jun 2006 at 4:45 AM
I am needing to find the output of the following code fragment:

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

Thanks in advance
Report
Re: Output Posted by Lundin on 8 Jun 2006 at 4:51 AM
: I am needing to find the output of the following code fragment:
:
: vector<int> v (10,5);
: v.push_back (3);
: cout<<v.front()<<""<<v.back();
:
: Thanks in advance
:

Compile it & run it. It usually does the trick.
Report
Re: Output Posted by HK_MP5KPDW on 8 Jun 2006 at 4:52 AM
: I am needing to find the output of the following code fragment:
:
: vector<int> v (10,5);
: v.push_back (3);
: cout<<v.front()<<""<<v.back();
:
: Thanks in advance
:

You don't have a compiler available to test it out? The constructor creates a vector consisting of 10 instances of the value 5. The push_back statment of course will add the value 3 to the end of the vector. It shouldn't be too hard to figure out what the front and back member functions would return in this case.
Report
Re: Output Posted by confused0874 on 9 Jun 2006 at 6:06 AM
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<int> v (10,5);
: : v.push_back (3);
: : cout<<v.front()<<""<<v.back();
: :
: : Thanks in advance
: :
:
: You don't have a compiler available to test it out? The constructor creates a vector consisting of 10 instances of the value 5. The push_back statment of course will add the value 3 to the end of the vector. It shouldn't be too hard to figure out what the front and back member functions would return in this case.
:

Report
Re: Output Posted by Lundin on 9 Jun 2006 at 6:15 AM
: 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:

#include <iostream>
#include <vector>
using namespace std;

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





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.