Midterm #2 Flashcards

(52 cards)

1
Q

types of input

A

arguments, cin&raquo_space;, and getline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

types of output

A

cout«

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

argc

A

argument counts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

argv

A

argument variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to compile a program

A

g++ -o example.out example.cpp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how to run a program

A

./example.out (inline arguments)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

(./example.out 3 10 abc) agrc

A

4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

(./example.out 3 10 abc) argv

A

argv[0], argv[1], agrv[2], argv[3]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

(./example.out A B C 1 2)
argc?

A

6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

(./example.out A B C 1 2) argv[3]

A

c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

(./example.out A B C 1 2) argv[5]

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

(./example.out A B C 1 2) argv[4] + argv[5]

A

we cannot have sum of two strings “1” + “2” is an invalid type of addition operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

atoi (str)

A

convert str to an int value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

atof (str)

A

convert str to a double value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

cout«

A

displays a prompt to whoever is running the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

std::

A

formal syntax (don’t need if “using namespace std”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

cin»

A

whatever the user puts into the program (becomes a variable)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

getline()

A

if the variable you want contains a space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

getline() (written out)

A

getline (cin, variable with space)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

\

A

the back-slash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

"

A

double quote marks

22
Q

\t

A

a horizontal tab

23
Q

\n

24
Q

std::endl

25
branching (tree)
if, switch
26
if (tree)
if (){ } if(){ }else{ }
27
bool type
Range: True (1) or false(0) && - and || - or ! - not
28
a==b==c
a==b && b==c
29
a != b != c
a != b && a != c && b != c
30
a > b > c
a > b && b > c
31
a < b < c
a < b && b < c
32
a in [b, c]
a >= b && a <= c
33
a ∈ [b, c]
a >= b && a <= c
34
a not in [b, c]
a < b || a > c
35
a !∈ [b, c]
a < b || a > c
36
one way if statement
if ( ){ }
37
two ways if statement
if ( ){ statement(s) of "true" case }else{ statement(s) of "false" case }
38
what can you use "if ... else" for
to make multiple branches
39
if ... else multiple branches example
if(condition1){ // statement_block1 ... } else if(condition2){ // statement_block2 ... } else if(condition3){ // statement_block3 ... } else{// statement_block4 ... }
40
common mistake of if statements
putting a semicolon after if expression, not using ==
41
what can you use "switch ... case" for
when there is more options than just true and false
42
switch ... case example
switch (integer-expression){ case Value 1: // statement(s) for Case 1 ... break; } case Value2: // statement(s) for case 2 ... break; ... ... default: // statement for default case ... }
43
what does (char) represent
a character data type that represents a single character
44
what does (string) represent
a string data type that represents a sequence of characters
45
what is a literal character
represented by single quotation marks ('a' '5')
46
message.length/message.size
shows the number of characters in a string
47
what is a literal string
represented by double quotation marks ("5" "csc117")
48
stringname[index]
what a variable is a a certain position
49
stringname[index] example
string s = "ABCD"; s[0] = 'P'; cout << s[0] << endl; // the output is "PBCD"
50
while loop
writes out what ever is looped as many times as you tell it to
51
while loop general example
while (condition){ // statement(s); // loop body }
52
what are the beginning parts of every program
#include #include #include using namespace std; int main(int argc, char * argv[]){ }