This function is used to gather input and include spaces.
getline()
Which loop is guaranteed to execute at least once?
do-while
in C++, the relational operators of AND and OR are represented by what?
&& - AND
|| - OR
Why is it generally bad practice to use the standard namespace?
name collisions. If you create a function with the same name in the standard namespace, C++ won't know which to select.
string name = "Harry Potter"
Provide the code needed to make a substring for the word "Potter"
name.substr(6,12);
OR
int pos = name.find('p');
name.substr(pos, 12);
To format output to currency, I would need to add these two functions to my cout statement.
fixed and setprecision()
This keyword is required to successfully break out of an infinite loop
break
This is the name given to a branching technique that mimics if statements, but immediately stores the result inside of a variable.
Ternary
This is the first step in the C++ compilation process to gather our enhanced source code.
Preprocessing
BONUS + 200
What step in the C++ compilation process gives us our object code?
Cast the following float variable to an int datatype safely.
float num = 3.14;
int newNum = static_cast<int>(num);
A datatype that often replaces ints in a for loop to count more realistic items
size_t
BONUS + 200
What is the memory limit for the size_t datatype?
for(i = 0; i > 3; i++)
What is wrong with the above for loop? [Give 2 issues]
missing datatype in initialization
Incorrect stopping condition
In a switch, to account for any missing scenarios, it's best to have a ____ case.
default case.
This variable acts as an alias to an already existing variable.
reference variable
Implement the following function prototype.
float divideNumbers(float a, float b);
if (b == 0) {
cerr << "cant divide by zero ";
return 0.0;}
return a/b;
If i want to include enumerated values for my input, I would need to _____ the >> operator.
overload
while (______)
finish the while condition to repeat until a number turns negative
while(number >= 0)
In a non-void function, every possible branch must eventually do what?
Return a value
What is the difference between a stream and a buffer?
A stream moves data from one source to some destination. (Input/Output)
A buffer is a temporary storage for data within a stream. (Variable)
The user inputted a string value for an int datatype. Safely handle this error and ask the user to re-enter input.
while(cin.fail()){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n'))
cin >> input; }
If i want to append data to an output file, I would need to include this parameter to my outputFile object creation.
std::ios::app
This while loop expression validates whether or a not a character is a number.
while(isdigit(char))
enum Direction {NORTH, SOUTH, EAST, WEST};
using a switch for this enum, the value EAST will be apart of what numbered case?
2
What is meant by the term "Dangling Reference"
A reference pointing to a memory location that no longer exists/no longer valid.
int num = 12345
append the number 6 to the end of this variable.
num = num * 10 + 6