What default types of variables are there?
Int, double, string, float, char
What operator would you use to check if two statements are both true?
&&
What's the difference between arguments and parameters?
Parameters are variables the function knows exists when defined, and arguments are variables passed into the function when called.
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 5; j++{
cout << i << " ";
}
cout << endl;
}
1 1 1 1
2 2 2 2
3 3 3 3
How would you declare an integer named x with the value of 23?
int x = 23;
What's the result of this loop running?
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
cout << j;
}
}
012340123401234
When would you pass by reference?
When you want to change a variable in a function without returning a value.
What error is thrown when accessing one more than the max index in a string?
string::npos
What is the result of 20 % 3?
2
When would you want to use two if statements in a row instead of an if/else block?
To check both if statements.
Assign it with the return value (which will be the changed variable) in the function.
In a function where you print every value in a vector of ints named v, how should you pass v to the function?
(const vector<int> &v)
What type of variable would you use to iterate through the indexes of an array?
unsigned int
What operator has the highest convention against other conditionals?
()
When a function returns from it's call, do its local variables keep their values?
No. Their values are discarded in memory.
What is selection sort?
Find the minimum element, move to the first position, then continue from the second position.