Comp Sci C++ Assessment
What is the symbol for modulus?
%
What is the symbol for division?
/
What is used for a block comment?
/* and */
What is used for inline comments?
//
How many bytes are used for char?
1 byte
How many bytes are used for int?
4 bytes
What does every C++ statement end with?
A semicolon ;
Why use namespace std; ?
Allows shorthand of cout<<, otherwise you would have to write std:: before all input or output commands
Why use <iostream> ?
Allows the computer to understand / define cout, need to include if you want to output or input data
What is int?
Any integer, no decimal points; ex. 3, -2, 0
What does /10 do?
Gets rid of the rightmost digit (digit in ones place)
What does abs(double num) do?
Gives the absolute value of a number
What does modulus do?
Gives the remainder
What does %10 do?
Gives the rightmost digit (digit in ones place)
What does getline() do?
Inputs a line of text
What does cin>> do?
Inputs information from the user
What is a variable?
Memory location that stores data
What do curly brackets {} do in C++?
Signify the start and end of a series of statements
What is char?
Single symbol in single quotes; ex. 'a', '?', '!'
What does return 0; do?
Stops the program
What happens if you divide with a double?
The result will be a double, the type of division used in math
What happens if you divide two int numbers?
The result will be an int
How do you connect outputs?
Use << between what you want to display
How do you make cin>> and getline() work together?
Use an extra getline() to clear the input system
What is the symbol for multiplication?
*
How many bytes are used for double?
8 bytes
What arrows are used for cout?
<<
What arrows are used for cin?
>>
What is double?
Any real number with decimal points; ex. 3.5, -2.31, 2.0
What is string?
Anything within quotes; ex. "hello", "true", " "
Why is cin>> sometimes less efficient than getline()?
Cin>> can only input one word
Why don't cin>> and getline() work well together?
Cin>> leaves enter in the input stream, causing getline() to think its done its job
What does declaring a variable do?
Creates a memory location
What does pow(double base, double exponent) do?
Finds the power of a given number
What happens if cin>> is used before getline()?
Getline() will not take the input
What is a block comment?
It exists on multiple lines
What is an inline comment?
It exists on one line of the program
What does cout<< do?
Outputs information to the screen
What is C++ order of operations? ]
Parentheses, Multiplication/Division/Modulus, Addition/Subtraction
What does round(double num) do?
Properly rounds a number
What does hypot(double a, double b) do?
Returns the hypotenuse of a right triangle
What does sqrt(double num) do?
Returns the square root of a number
What does floor(double num) do?
Rounds a number down
What does ceil(double num) do?
Rounds a number up
What does int main() do?
Runs the program, the program counter starts at the first line within it
What do endl; and "\n" do?
Tell the computer to go to a new line
Why would you use <cmath>?
To use the functions in the math library
What is bool?
True or false; NOT within quotes
What is a literal?
Values that do not change
What do we use instead of literals?
Variables