Intro to C++ Flashcards
What does the #include directive do?
Causes another file to be inserted into the program. Usually library files that contain specific definitions.
C++ is case sensitive, which means…
Anything written in lowercase will not be read the same way as something in uppercase.
All programs must have a…
main function.
What are the two ways that main can be defined?
int main() and void main(void)
What do output statements do?
send the user messages, results, questions, etc from the computer.
What format does an output statement usually take?
the cout object, the insertion operator, and variables or constants to be displayed.
What is the insertion operator?
«
What is an escape sequence?
something that performs a specific output task when enclosed in quotes.
What does \n do?
causes the cursor to go to the next line
what does \t do?
causes the cursor to go to the next tab stop.
What does \a do?
Causes the computer to beep
What does \ do?
Causes a backslash to be printed.
What does ' do?
Causes a single quote to be printed.
What does " do?
Causes a double quote to be printed.
what does endl do?
returns output to next line.
What is an identifier?
names or symbols used by the programmer to refer to times such as variables, named constants, functions, classes, ect.
What words are off limits as identifiers?
Any key words or reserved words.
What must an identifier be comprised of?
Only letters, numbers, or the underscore.
What is the rule for the first character of an identifier?
it must be a letter or underscore.
What do variables refer to?
memory locations in which the value stored may change throughout the execution of the program.
What do named or symbolic constants refer to?
memory locations in which the values do not change during the course of the program.
You must define or declare a variable before you may use it!
.
What is the format of a variable definition?
datatype variablename;
What is false represented as in a computer
Zero
What is true represented as in a computer
True is one and any number other than zero
What does datatype char hold
A single character value
What Are c-strings?
Arrays of characters
What are string objects
Variables that have to be declared of the string class
What preprocessor directive is required to use the string class
String
What format do constant declarations have
Const datatype identifier = value
What does data type determine?
How the data will be stored and what types of operations can be performed on this data.
What types of data types are there?
integers, real numbers, characters, boolean
What subtypes of integer data types are there?
short, unsigned short, int, unsigned int, long, unsigned long, long long int, unsigned long long
What types of floating point data types are there?
float, double, long double
What is boolean data?
data that is either true or false
How can you declare multiple variables with the same data type?
in a single statement.
datattype var1, var2, var3;
What are assignment statements used for?
to store values in the memory locations.
What is the assignment operator?
=
When are named constants assigned?
At the time they are declared.
When can assignments to variables occur?
At declaration, or any time after.
How do assignment statements work?
The result of whatever is on the right side, is stored in the variable on the left side.
What does truncated mean?
Data is lost to change a value.
When are numbers truncated?
When they do not fit in the data type they are being stored in.
How many characters can data type char store?
1 character
What type of quotation marks must you use with the char data type?
Single quotes
Why do you use single quotes with char data type?
Because double quotes include an end character, so is stored as one more character than it actually.
What are strings?
a collection of characters
What are the two methods of creating strings?
c-strings and string objects
What is a c-string?
an array of characters
When can C-strings be assigned
at the time of declaration.
What do strings require you include?
the string preprocessor directive
What are the three types of operators?
unary, binary, and ternary
What is a unary operator?
operator that requires one operand.
what is a binary operator?
operator that requires two operands
What is a ternary operator?
an operator that requires three operands.
What does the operator modulus (%) do?
Finds the remainder of the division of two integers.
integers operated on by integers will result in…
integers
floating points operated on by integers will result in…
floating points
What is the order of operations for operators?
parenthesis, unary negation, multiplication/division/modulus, addition/subtraction
What order are operations of equal precedence performed in?
from left to right.
Any number without a decimal point is assumed to be…
an integer.
How do multiple assignments work?
many variables can be assigned the same number by placing them as x=y=z=a=b=c=3.0;
What are the Four types of Control Structures?
Sequence, Branched, Loops, Functions
Describe sequence (control structure)
statements are executed in order they are written
What is the Branched control structure?
some statements may be executed only when a specific condition is met.
What is the loop control structure?
statements are repeated
describe the functions control structure
a group of statements are executed at various times in the program.