Programing 1 - Chapter 3

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/28

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

29 Terms

1
New cards

stream extraction operator

», used with cin

2
New cards

cmath header file

Allows for more complex math, like exponents (pow(x, y))

3
New cards

Type conversion

When two variable are different data types, they must be converted to the same to use them together

4
New cards

Type coercion

When a computer automatically uses type conversion

5
New cards

Overflow & Underflow

When a value is too big for its data type, it will automatically become the smallest number possible, and vice versa

6
New cards

Type casting

Manually promoting or demoting a variable’s data type like so:

static_cast<long int>(variableName)

7
New cards

Multiple assignment

Assigning multiple variables the same value like so:

a = b = c = 12

8
New cards

Combined assignment

When a variable’s previous value is used in its own assignment:

myFoo = myFoo + 1

9
New cards

setw()

Stands for set width. Determines the MINIMUM width of cout by adding whitespace IF NEEDED. Number goes in parentheses

10
New cards

<iomanip>

Header file, required for setw and setprecision.

11
New cards

Setprecision()

Controls how many digits of a int or float will be displayed.
Note that this does not round, it truncates

12
New cards

Fixed

Use after setprecision. This controls how many decimal digits will be displayed on a float or int. Note that 5.5 would turn into 4.70000 if you used setprecision(5)

used with setpre. or by itself also makes all numbers stay as digits and not scientific notation

13
New cards

Showpoint

Use after setprecison. Without showpoint, setprecision takes away numbers if needed. With showpoint, it will add zeroes if there are too few.

14
New cards

Left

Used with setw(), and will push the value to the left side, and not the right. This will continue throughout all of the code unless right is used.

15
New cards

getline()

cin function that takes as much data until [Enter] is pressed, including spaces.

Has two parameters. Input (cin), then the variable to store it to

getline(cin, myString)

16
New cards

Cin.get()

cin function that takes one input, no matter what, including a space or a enter key. One parameter, which is the variable to store the input to.

17
New cards

cin.ignore()

cin function that deletes a certain number of characters inputted, or leftover characters from past cin’s, like \n. Can take between 0 and 2 parameters

  1. Deletes the next character

  2. Use one number. Deletes that many characters

  3. Use one character or something like \n. Either deletes all letters leading up to that character, including that character, or deletes the amount of characters specified in 1. Whichever comes first.

18
New cards

Random number engine

Creates a bunch of random binary. We use random_device engine in this class. Looks like the following:

random_device myEngineVariable

Now random_device has been set to the variable

19
New cards

Distribution object

Translates random binary from the random number engine into numbers.

We use uniform_int_distribution in this class. Looks like so:

uniform_int_distribution<int> myDistObj(0, 100)

20
New cards

Generating random numbers

Use pre-initialized distribution object and random number engines, then do the following

randomNumberOutput = myDistObj(myEngine)

21
New cards
22
New cards
23
New cards
24
New cards
25
New cards
26
New cards
27
New cards
28
New cards
29
New cards