I cant seem to get this programm to run and i dunno what the output will be can some one help me ?
the code is
vector <int> myinventory(4);
myinventory[0] = 2;
for(int i = 1; i <= 3; i++)
& {
& & myinventory[i] = 2*myinventory[i - 1];
& & }
myinventory.push_back(34);
for (int i = 0; i< myinventory.size();i++)
& & {
& & & & cout << myinventory[i] <<" ";=""
& & }
1
Expert's answer
2011-05-16T11:21:33-0400
1) First you should define variable as follows:
& vector<int> myinventory(4); Instead of vector myinventory(4);
2) the last line cout<<myinventory[i] <<" ";="" & contains an error. It should be like this: cout<<myinventory[i] <<"; ";
Corrected program:
vector<int> myinventory(4); myinventory[0] = 2; for(int i = 1; i <= 3; i++) { & myinventory[i] = 2*myinventory[i - 1]; } myinventory.push_back(34); for (unsigned int i = 0; i<myinventory.size();i++) { cout<<myinventory[i] <<"; "; };
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment