100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

CPP Advanced Programming in C++ Cisco Chapter 1 Assessment

Rating
-
Sold
-
Pages
30
Grade
A+
Uploaded on
02-09-2022
Written in
2021/2022

CPP Advanced Programming in C++ Cisco Chapter 1 Assessment

Institution
Course










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
September 2, 2022
Number of pages
30
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Question 1
pts
What will happen when you attempt to compile and run the following code?

#include <vector>
#include <iostream>

int main ()
{
std::vector<int> v1; // LINE I
v1.push_back(10); // LINE II
std::cout<<v1.front()<<":"<<v1.back()<<std::endl; // LINE III
return 0;
}




compilation fails due to error in line II



program displays 0:10



compilation fails due to error in line III



compilation fails due to error in line I



code compiles and executes successfully



Question 2
pts
Which statement is true about the code below?

#include <vector>
#include <iostream>
using namespace std;
int main ()
{
vector<int> v1(4, 3);

, v1.push_back(4);
for(vector<int>::iterator i = v1.rbegin(); i != v1.rend(); ++i)
{
cout << *i << " ";
}
cout<< endl;
return 0;
}




program will not compile



program displays 4 3 3 3 3



v1.capacity() and v1.size() return the same value



program displays 4 4 4 4



program displays 3 3 3 3 4



PartialQuestion 3
0. pts
Which sentences are 100% true about the code below (multiple choice) when control
reaches return. Choose all that apply.

#include <vector>
#include <iostream>

using namespace std;

int main ()
{
vector<int> v1(10, -1);
vector<int> v2;
v2.reserve(10);
for(unsigned i=0; i < 10; i++)
{

, v2.push_back(i);
}
return 0;
}




both vectors v1 and v2 have the same capacity



value returned by size() is the same for vectors v1 and v2



size of vector v2 less than 20



code will not compile



Question 4
pts
Which sentence is 100% true about the code below when control reaches return?

#include <vector>
#include <iostream>
#include <stdexcept>

using namespace std;

int main ()
{
int tab[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
vector<int> v1(tab, tab+10);
vector<int> v2(v1.size(), 0);
try
{
for(unsigned i=0; i<=v1.size(); ++i)
{
int tmp = v1[i]; // LINE I
v1[i] = v1.at(v1.size()-i); // LINE II
v1.at(i) = tmp; // LINE III
cout<<v1[i] << " ";
}
}
catch(...)
$4.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
arviemontemayor

Also available in package deal

Get to know the seller

Seller avatar
arviemontemayor AMACC
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
3 year
Number of followers
0
Documents
39
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions