Shared Flashcard Set

Details

C++
notes on programming
54
Computer Science
Not Applicable
09/27/2012

Additional Computer Science Flashcards

 


 

Cards

Term
comments
Definition
//comment
/*comment
comment*/
Term
cout
cin
Definition
iostream library
using namespace std
cout<cin>>x
Term
header file
Definition
#ifndef
#define
//declarations
#endif
Term
macro define
Definition
#define indentifier replacement
#define YEN_PER_DOLLAR 127
Term
sizeof()
Definition
shows num of bytes in type or variable
iostream library
Term
signed
Definition
holds neg and pos nums from
-128 to 127
Term
unsigned
Definition
holds only pos nums from 0 to 255
Term
equality operator
Definition
if(x==5)
do something;
Term
ASCII code
Definition
char chchar=97;
cout chchar; will print a
use int cast to print number
cout (int)chchar;
Term
newline
Definition
\n makes new line
Term
tab
Definition
\t big space/tab
Term
alert
Definition
\a makes samll beep
Term
backspace
Definition
\b moves cursor back a space
Term
formfeed
Definition
\f moves cursor to next page
Term
carriage return
Definition
\r moves cursor to beggining of line
Term
vertical tab
Definition
\v
Term
single quote
Definition
\'
Term
double quote
Definition
\"
Term
backslash
Definition
\\
Term
question mark
Definition
\?
Term
unary plus
Definition
+x value of x
Term
unary minus
Definition
-x negation of x
Term
assignment
Definition
y=x
assign y value to x
Term
modulus assignment
Definition
x%=y
put remainder of x/y in x
Term
prefix increment
Definition
++x
increment x, thenevaluate x
Term
prefix decrement
Definition
--x
decrement x, then evaluate x
Term
postfix increment
Definition
x++
evaluate x,then increment
Term
postfix decrement
Definition
x--
evaluate x,then decrement
Term
comma
Definition
x,y
evalute x then y, return value of y
Term
arithmetic if
Definition
c?x:y
if c is true then x, otherwise y
Term
logical NOT
Definition
!x
true if x is false
Term
logical AND
Definition
x&&y
true only if both are truee
Term
logical OR
Definition
x||y
true if either x or y are true
Term
left and right shift
Definition
x<x>>y all bits in x shifted right y bits
(binary 1's shifted,if pushed off end,lost)
Term
bitwise NOT
Definition
~x all bits in x flipped
0110=x
~x=1001
Term
Bitwise AND
Definition
x&y
0 1 0 1 // 5
0 1 1 0 // 6
0 1 0 0
adds to one if both are ones
Term
Bitwise OR
Definition
x|y
0 1 0 1 // 5
0 1 1 0 // 6
0 1 1 1
adds to one if either has one
Term
BItwise XOR
Definition
x^y
0 1 0 1 // 5
0 1 1 0 // 6
0 0 1 1
ony evals to one if only one of them has a one
Term
static keyword
Definition
makes global variable file scope or if applied to variable in a block makes it fixed duration so it stays after block is destroyed
Term
casting
Definition
changes type
int x = 10;
int y = 4;
float fValue = (float)x /y;
Term
static cast
Definition
float fValue = static_cast(nValue1) / nValue2;
-only does standard type conversions
Term
enum
Definition
way to create own data type
ex.
enum Color
{COLOR_BLACK
COLOR_GREY}
dec enum var- Color ecolor =COLOR_GREY
automatically recives num value
Term
typedef
Definition
allows alias for data type
ex. typedef long miles;
Term
structs
Definition
group variables of mixed data types together into a single unit
ex. struct Employee
{
int nID;
int nAge;
float fWage;
};
Employee sFrank; // create an Employee struct for Frank
sFrank.nID = 15;
sFrank.nAge = 28;
sFrank.fWage = 18.27;
Term
if statement
Definition
if (expression)
statement
use block{} for multiple statements
add else if, and else for more possiilites
Term
switch statement
Definition
for multiple conditions
switch (cChar)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
return true;
default:
return false;
}
Term
goto staement
Definition
makes cpu jump to another spot in code

statmentlabel:lots of code
goto statementlabel;
Term
while statement
Definition
while (expression)
statement;
-
Term
do while statement
Definition
do
statement;
while (condition);
Term
for statement
Definition
for (init-statement; expr1; expr2)
statement;
for (int iii=0; iii < 10; iii++)
cout << iii << " ";
multiple declarations:
for (int iii=0, jjj=9; iii < 10; iii++, jjj--)
cout << iii << " " << jjj << endl;
Term
array
Definition
access multiple variables through one index
ex. int anTestScores[30]; // allocate 30 integers
int anTestscores[0]=69;
Term
non-constant integer arrays
Definition
const int nArraySize = 5;
int anArray[nArraySize];
Term
intilializer list
Definition
int anArray[5] = { 3, 2, 7, 5, 8 };
if not intialized-equal 0
Term
enum-arrays
Definition
enum StudentNames
{
KENNY, // 0
KYLE, // 1
STAN, // 2
BUTTERS, // 3
CARTMAN, // 4
MAX_STUDENTS // 5
};

int anTestScores[MAX_STUDENTS]; // allocate 5 integers
anTestScores[STAN] = 76;
Supporting users have an ad free experience!