Created by Adriana Vincelli-Joma
over 3 years ago
|
||
Question | Answer |
function prototype | uses description of types of arguments when declaring/defining function |
Components of function prototype | - name - input parameters (parentheses) - type of return value (or void) |
void | specifies that no value is returned |
return | - returns value from function - exits function back to point right after function |
Purpose of C Library | someone already solved your problem and gave it more thought and debugging |
Using C Function Library | - find programming reference - description of function demonstrates syntax of code - has at least one #include line, showing you header file containing function prototype - duplicate #include line in file so function is properly declared |
librarian | manages groups of object modules |
5 Execution Control Statements | - if-else - while - do-while - for - switch |
if-else | if(expression) statement else statement - if condition is true, first statement is executed; if it is false, second statement is executed |
while | while(expression) statement - statement repeats until controlling expression evaluates to false |
do-while | do statement while(expression); - statement always executes at least once, even if expression evaluates to false first time |
for | for(initialization; conditional; step) statement -allows you to execute block of code specified number of times |
initialization | code executes once at very beginning |
conditional | tested before each iteration |
step | executes at end of each loop |
break | quits loop without executing rest of statements in loop |
continue | stops execution of current iteration and goes back to beginning of loop to begin new iteration |
while(true) | do loop forever |
switch | statement selects from among pieces of code based on value of integral expression switch(selector) { case integral-value 1 : statement; break; case integral-value 2 : statement; break; (...) default: statement; } |
goto | - statement used to jump from anywhere to anywhere within a function - makes it difficult to trace control of flow of program |
recursion | programming technique whereby you call function you're in - function calls itself directly/indirectly |
Basic Operators | addition: + subtraction/unary minus: - multiplication: * division: / assignment: = modulus: % ; remainder from division |
precedence | defines order in which expression evaluates when several different operators are present |
auto-decrement operator | -- ; decrease by one unit |
auto-increment operator | ++ : increase by one unit |
++A | operation first performed and resulting value is produced |
A++ | current value is produced, and then operator is performed |
Basic Data Types | - char - int - float - double |
char | character storage and uses minimum of 8 bits |
int | stores integral number and uses minimum of two bytes of storage |
float | single-precision floating point; 4 bytes |
double | double-precision floating point; 8 bytes |
bool | two states expressed by the built-in constants true (converts to integral one) and false (converts to integral zero) |
long | modify max value data type will hold |
short | modify min value data type will hold |
signed | represent both positive and negative values |
unsigned | integer can never be negative |
pointer | type of variable that holds an address |
dereference | access or manipulate data contained in memory location pointed to by a pointer; * |
address | location of object in memory; & |
reference | alternative name for an existing variable |
pass by value | pass arguments to function, copy of argument is made inside function |
pass by reference | parameter becomes alias for argument; argument and parameter refer to same area of storage |
Purpose of Pointer | hold address and use address to modify original value |
Pointer vs Reference | - pointers store address of variable - references refer to existing variable in another name |
scoping | tells you where variable is valid, where it is created, and where it gets destroyed |
"goes out of scope" | where variable gets destroyed |
on the fly | allows you to define variables anywhere in scope, so you can define variable right before you use it |
global variable | defined outside all function bodies and are available to all parts of program |
local variable | occur within scope; automatically come into being when scope is entered and automatically go away when scope closes |
register | make access to variable as fast as possible |
static | - value is extant throughout life of program - initialization is performed only first time function is called - unavailable outside scope of function, so it can't be inadvertently changed |
extern | tells compiler that variable/function exists, even if compiler hasn't yet seen it in file currently being compiled |
const | represents constant |
volatile | prevents compiler from performing any optimizations based on stability of variable |
const vs volatile | - const variable cannot be changed - volatile can change at any time |
static vs volatile | - static variable initialization is performed only first time function is called, data retains its value between function calls -volatile variable always read whenever value is required, even if it was just read line before |
Relational Operators | less than: < greater than: > less than/equal to: <= greater than/equal to: >= equivalent: == not equivalent: != |
Logical Operators | true: non-zero value false: zero value and: && or: || |
Bitwise Operators | manipulate individual bits in number and: &; produces one in output bit if both input bits are 1; otherwise produces 0 or: |; produces one in output bit if either input bit is 1; produces 0 if both input bits are 0 xor: ^; produces 1 in output bit if one or other input bit is 1, but not both not: ~; only takes one argument; ones complement operator nor: opposite of input bit; 1 if input is 0; 0 if input is 1 |
Shift Operators | left-shift operator: <<; produces operand to left of operator shifted to left by number of bits specified after operator right-shift operator: >>; produces operand to left of operator shifted to right by number of bits specified after operator |
Unary Operators | logical not: !; takes true value and produces false value unary minus: - ; produces negative of value unary plus: + ; provides symmetry with unary minus address-of (&) and dereference (* and ->): used with pointers |
ternary operator | if-else: - three operands - a = --b ? b : (b = -99) |
comma operator | - separate variable names in multiple definitions - used in function argument lists - used as operator to separate expression |
cast | changes one type of data into another |
static_const | - typical castless conversions - narrowing conversions -forcing conversion from void* -implicit type conversions -static navigation of class hierarchies |
const_cast | convert from const to nonconst or from volatile to nonvolatile |
reinterpret_cast | pretends object is bit pattern that can be treated as if it were an entirely different type of object |
sizeof | gives info about amount of memory allocated for data items |
asm | escape mechanism that allows you to write assembly code for your hardware within C++ program |
aliasing | situation where two different expressions or symbols refer to same object |
typedef | create alias that can be used anywhere in place of type name |
struct | collects groups of variables into structure |
enum | automatically enumerates any list of identifiers you give it by assigning them values of 0, 1, 2, etc. |
union | piles all data into single space |
array | -clumps variables together, one right after the other, under single identifier name -set of consecutive memory locations used to store data |
array identifier | hook into square-bracket syntax; read-only pointer to beginning of array |
pointer arithmetic | - cannot add two pointers -if you subtract pointers, result is number of elements between two pointers - can add/subtract integral value and pointer |
preprocessor debugging flag | #define: defines one or more debugging flags #ifdef: test flags #undef: removes code |
assert() | convenient debugging macro; in standard header file <cassert> |
NDEBUG | flag used to <cassert> to change way code is generated by macros |
function pointer | variable that stores address of function; allows you to pass and store functions to variables |
separate compilation | breaking code into number of translation units |
make | utility that allows programmer to manage compilation and linking of separate program units (source files) and libraries |
makefile | text file that contains instructions for make; description of how to compile program |
macros | allow convenient string replacement; invoke C++ compiler |
target | file that you want rebuilt |
Use of Macros | - = : used to identify macro - $ and () : expand macro |
Want to create your own Flashcards for free with GoConqr? Learn more.