Questions C ++: Compare and Contrast The Loops That Used A For With Those
Questions C ++: Compare and Contrast The Loops That Used A For With Those
1)
2)
3)
4)
5)
6)
Compare and contrast the loops that used a for with those
using a while. Are there advantages or disadvantages to using either
form?
Write a lambda that captures a local int variable and
decrements that variable until it reaches 0. Once the variable is 0
additional
calls should no longer decrement the variable. The lambda should
return a
bool that indicates whether the captured variable is 0.
Explain the differences among the three kinds of insert
iterators.
Use reverse_iterators to print a vector in reverse
order.
List the five iterator categories and the operations that each
supports.
Give an example of when each of list, vector, deque,
map, and set might be most useful.
1.
2.
3.
4.
5.
6.
7.
#include <iostream>
using namespace std;
template<typename T>
void loopIt(T x)
{
int count = 3;
T val[count];
for (int ii=0; ii < count; ii++)
{
val[ii] = x++;
cout << val[ii] << endl;
}
};
int main()
{
float xx = 2.1;
loopIt(xx);
}
13) How many streams are automatically created when executing a program?
a) 1
b) 2
c) 3
d) 4