• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/46

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

46 Cards in this Set

  • Front
  • Back
What is a line that starts with # called?

preprocessor directive

What are namespaces used for?


What does namespace std do?


namespaces organize the names of program entities




namespace std declares that the program will be accessing entities whose names are part of the namespace called std. In order for programs use the entities in iostream, it must have access to the std namespace

What is the purpose of int main()

marks the beginning of a function

What is a function? How do you know it's a function?



A function is a group of one or more programming statements that collectively has a name




nameoffunction() <-- parentheses indicate it's a function

Is C++ case-sensitive?


YES




main != Main




m and M are entirely different characters

All statements that make up a function are enclosed in a set of



braces { }


"Programming is great fun!"


What is the group of characters inside the quotation marks called?


string literal or string constant


What does each of these mean:


// # < > ( ) { } " " ;


//Comment #preprocessor directive <encloses a file name when used with #include > ( )used in name a function {group of statements, like contents of a function} "string of characters" end of complete programming statement;
What type of output does cout produce?

Console output (in terminal as opposed to a window)


cout is a stream object. What does this mean?


What is << ?


Stream object: works with streams of data




<< stream insertion operator

Unless you specify otherwise, how it the information sent to cout displayed?



In a single stream (on a single line)

What are two ways to instruct cout to start a new line?


stream manipulator: endl creates a new line


i


nsert an escape sequence: \followed by one or more control characters. \n is the newline escape sequence. Must be in quotation marks

What does each of these escape sequences mean:


\n \t \a \b \r \\ \' \"


\n - newline \t - tab \a - alarm \b - cursor backs up one \r - cursor goes to beginning of next line \\prints backslash \' prints ' \" prints "

Why is iostream included?
input-output stream library. allows program to compile cout and cin

What are variables? What are literals?


Variables represent storage locations in the computer's memory.




Literals are constant values that are assigned to variables. Literals are also called constants. A literal is a piece of data written directly into the program's code


What is included in a variable definition?

variable's name and the type of data the variable will hold

What is included in a variable assignment?

variable name = value;

What happens when a variable is sent to cout vs. a string literal?


contents of variable are printed


characters inside quotations are printed

Before numbers can be displayed on the screen they must first be converted to strings. Fortunately....

cout handles the conversion automatically

What is an identifier?

programmer-defined name that represents some element of a program. do not use C++ key words. name should reflect use.
What are three rules for using identifiers?


First character must be a-z, A-Z, or _


After the first character, any letters, numbers, or _ can be used


Uppercase and lowercase characters are distinct. ItemsOrdered != itemsordered

What kind of data can integer variables hold?

Whole numbers

What are considerations for selecting a numeric data type?


- largest and smallest numbers that may be stored in the variable


- how much memory the variable uses


- whether the variable stores signed or unsigned numbers


- the number of decimal places of precision the variable has

What does unsigned mean?

nonnegative only






short int: [-32768, 32767]


unsigned short int: [0, +65535]


How do you abbreviate each of these:


short int, unsigned short int, int, unsigned int, long int, unsigned long int, long long int, unsigned long long int


Remove int from each (except just int)


What do you do if you want an integer literal to be treated as a long long int?

append LL at the end of the number




long long amount;


amount = 32LL;


How do you express hexadecimal numbers in C++? Octal numbers?


Hexadecimal: 0x22 (precede number with 0x)




Octal: 022 (precede number with 0)

What is the char data type used for? How are character literals assigned?


stores individual characters


enclose the character in ' '


char letter='n';




don't confuse string literals " " and char literals ' '

When you work with characters, what are you actually working with?


Numbers




ASCII: American Standard Code for Information Interchange


How does C++ know how long a string literal is?

Stores a null terminator/null character ( \0 ) at the end

What needs to be included to use the string class?

#include <string>
What are floating-point data types used for?


used to define variables that can hold real numbers




floating-point numbers allow for fractional values

What are the three floating point data types?



float (single precision)


double (double precision)


long double (longest)



What's an easy way to write large numbers?

E notation




(similar to scientific notation)

How can you force a literal to be stored as a float? As a long?

append an F to it




e.g., 1.2F




Append an L

What happens when a floating-point value is assigned to an integer variable?



the fractional part is truncated

What are Boolean (bool) variables set to?

true or false
How do you determine the size of a data type on any system?


sizeof(nameofdatatypeyouwantthesizeof) operator

What is assignment? What is initialization?



Assignment operation assigns/copies a value into a variable


int x;


x=4;




Initialization: value is assigned to a variable as part of the variable's definition


int x=4;

What is the auto key word used for?

use auto instead of a data type. compiler will determine data type from initialization value

Define scope of a variable


variable's scope: part of the program that has access to that variable




variable must be defined before it is used

How are unary, binary, and ternary operators defined?


define by the number of operands they require


-7 is unary


7*8 is binary

What is the % operator called? What is it used for?


%: modulus operator


only works with integer operands. returns the remainder of integer division

How do you write multi-line comments in C++? Single line?


//single line


/* multi-line


comments */

What is a named constant?

it's like a variable, but its content is read-only and cannot be changed while the program is running




const double InterestRate = 0.09;

What does programming style refer to?

The way source code is visually arranged