Shared Flashcard Set

Details

C++ ch3 part 1
part 1
24
Computer Science
Undergraduate 1
12/30/2010

Additional Computer Science Flashcards

 


 

Cards

Term
what is the stream extraction operator?
Definition
this is the stream extraction operator (>>) i.e. cin
Term
what happens when a variable is defined as an integer, but it is entered as a floating point?
Definition
the decimal will not be read
Term
how do you enter a string array and how do you define it?
Definition
the string must be defined i.e. char, and how many spaces it will occupy, i.e. char name[21], with the +1 being the null terminator
Term
if you have two variables, i.e. length and width, how would you use cin to enter them right after another?
Definition
cin>>length>>width;
Term
what is a string array, in general terms, when do you use it?
Definition
its a string of characters that you can enter, i.e. John
Term
what is the header that you must include to use the pow function?
Definition
cmath
Term
how would you state 4 to the power of 2?
Definition
pow(4.0,2.0) remember to use #include cmath
Term
what is type coercion?
Definition
this is when C++ automatically converts operands to the same type, i.e. all double or all int or all float
Term
please refer to pg.97 for data type ranking!
Definition
page 97
Term
what is the highest data type?
Definition
long double
Term
what is the lowest data type?
Definition
int
Term
what usually happens when an integer overflows?
Definition
it goes to the lowest value possible (wraps around)
Term
what usually happens when an integer underflows?
Definition
it goes the highest value possible (because it wraps around from the lowest value)
Term
what is the command for typecasting a variable?
Definition
static_cast type (value)
Term
with static casting, why is this statment dangerous? perMonth = static_cast double (books/months)?
Definition
because it will result in integer division
Term
what is a named constant, what is it used for?
Definition
making a variable a read only, useful for assigning variables when you want to use words, not numbers
Term
what is the command for a constant, give an example for a constant of x?
Definition
const double x = 0.22
Term
why do you use usually use constants with cstrings?
Definition
you use them to identify the size of the array, i.e const int SIZE = 21, char name [SIZE]; makes it easier to use and understand
Term
what is the preprocessor command to use setw?
Definition
iomanip
Term
what is the purpose of using setw, how do you use it (example)?
Definition
to set the amount of space for a variable following it
Term
how do you use the setprecision manipulator?
Definition
use it to set a number of predefined signigicant digits, setprecision(5) for example, if setprecsion(3) and x = 28.92786 output = 28.9 or 3 sig. fig. regardless of decimal
Term
how do you use the fixed manipulator?
Definition
cout<< setprecison(2) << fixed; this will automatically set the variable to a decimal
Term
how do you use the showpoint manipulator?
Definition
it will add zeroes to a number till you hit the predetermined size. i.e. double x=123.4; cout<
Term
how do you use left and right manipulators?
Definition
you use them for justification to the left or right, cout<
Supporting users have an ad free experience!