Variable arithmetic & output basics
Branches
Important stuff to know
Loops
Arrays & Vectors
100

What does the 'cout' statement do in c++?

it prints stuff out

100

What is the final value of numItems?

bonusVal = 10;
numItems = 1;
if (bonusVal == 10) {
   numItems = numItems + 3;
}

4

100

How do we check if a number is even?


% by 2


100

Which statement is used to immediately jump out of a loop and execute the next line of code?

Break

100

Which function is used to append an element to the end of a vector?

push_back()

200

the output of the following code:

    int x = 99;

    x /= 2;

    cout << x % 5;

4

200

Is x =< y a valid expression?


no

200

When should you use a while loop instead of a for loop?

When you don't know how many iterations there will be

200

Which statement will end the current iteration of a loop and begins the next

Continue

200

Declare an integer array with a size of 3

int arr[3];

300

what is 7 in binary?

0111

300

What is y's ending value if the input is 15?
int x;
int y = 0;
cin >> x;
if (x = 20) {
   y = 3;
}

3

300

What are all the rules for variable names (how do we know if they are valid identifiers)

be a sequence of letters (a-z, A-Z), underscores (_), and digits (0-9)

start with a letter or underscore

300

Which type of loop always runs at least once?

do while loop

300

Which of these is NOT a vector function

.pop_back()

.back()

.size()

.length()

.at()

.push_back()

.length()

400

Which line(s) of code give an error?

    double pi = 3.14;

    circleRadius = 5;

    int perimeter = 2(pi * circleRadius);

    cout << perimeter;

circleRadius = 5;

int perimeter = 2(pi * circleRadius);

400

If the input sets int x with 5 and int y with 7, what is the ending value of z? z is declared as a boolean.

z = (x > y);

false

400

There are about 8 billion people on this planet, create a variable named humanPop that can hold this number

long long humanPop;

OR 

unsigned long long humanPop;

400

How many times will this loop run?

int x = 0;

for(int i = 0; i <= 10; i++){

   x++;

}

11

400
Write a line of code to assign a variable x with the value of the last element of a vector named v

x = v.size()-1;

OR

x = v.back();

500

the output of the following code

    int x = 10;

    x++;

    cout << (sqrt(4+x/20));


2

500

the final value of y

int x = 6;
int y = 8;
if (x < 10) {
   if (y < 5) y = y + 1;
   else y = 7;}
else y = y + 10;

7

500

what is the output of the following code:

    double x = 0.1;

    double y = 0.2;

    if(x + y == 0.3)

        cout << "true" << endl;

    else

        cout << "false" << endl;

false

500

What is the missing line of code in the following program?

    int x = 0;

    int sum = 0;

    while(x < 10){

        sum += x;

    }

x++ (or any way to increment x)

500

Write a program to print the elements of a vector of any size. The name of the vector is v

for(int i = 0; i < v.size(); i++) 

    cout << v.at(i);