Comp Sci Ch 1, Ch 2 Flashcards

1
Q

What is a program?

A

a set of instructions executing at one time

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

What is a variable?

A

holds a value, stores it in memory

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

What is an algorithm?

A

a sequence of instructions that solve a problem

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

What are the 1st two lines of code?

A

include <isostream></isostream>

using namespace std;

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

What outputs onto screen?

A

cout «

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

What gets input?

A

cin&raquo_space;

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

What does an int hold?

A

an integer value

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

What starts the main function?

A

main () and everything inside {}

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

What ends a program?

A

return 0;

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

What starts a new line?

A

endl; or /n

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

What is a single line comment?

A

//text

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

What is a multi line comment?

A

/* text */

/*text
*text
*text */

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

What makes a program more readble?

A

whitespace

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

What is a syntax error?

A

violates programming language

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

How should you fix errors?

A

one at a time and compile

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

What is a logic error?

A

a bug, your sequencing or math is wrong

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

What is a bit?

A

a switch, binary digits, 0 and 1

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

What is a ciruit?

A

a connection of switches

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

What is a memory?

A

instructions and data stored in 0s and 1s in thousands of addressed locations

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

What is a processor?

A

executes instructions of program

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

What are machine instructions?

A

instructions represented in 0s and 1s

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

What is an executable program?

A

sequence of machine instructions

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

What are assembly language instructions?

A

translate high level (words and numbers) language to executable programs

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

What is moore’s law?

A

the doubling of integrated circuits capacity every 18 months

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

How many bits in a byte?

A

8 bits = 1 byte

26
Q

Binary has a power of…

A

2

27
Q

What does an assignment do?

A

assigns a variable a value

28
Q

What are the rules for identifiers/variable names?

A

-sequence of letters, underscores, and digits
- start with letter or underscore
- no spaces or special characters
-case sensitive

29
Q

What is a reserved word?

A

key word that is part of the language and cannot be used as an identifier

30
Q

What is an expression?

A

individual item or combination that evaluates to a value

31
Q

What is a literal?

A

a specific value in code

32
Q

What is a floating point number?

A
  • a real number with a decimal point
    -measures measurements and fractions of countable items
33
Q

What are the ways to force a computer to see a data type differently?

A
  1. change literal data type
  2. multiply by literal of that data type (times 1.0 goes first)
    3.force it into a variable of that data type
  3. use type casting
34
Q

What happens when you divide a floating point number by 0?

A

NaN, not a number

35
Q

What is data cast?

A

changing the number of places after the decimal
cout &laquo_space;fixed &laquo_space;setprecision(2) &laquo_space;myFloat;

36
Q

How do you initialize a constant variable?

A

const type NAME_OF_VAR;

37
Q

What is used to enable math functions?

A

include <cmath></cmath>

38
Q

What is an argument?

A

any function input values appearing within (), separated by a comma if more than one

39
Q

What is the function of square root of x?

A

sqrt(x)

40
Q

Function of a float absolute value and abosolute value

A

fabs(x) and abs(s)

41
Q

Power function of x to the power of y

A

pow(x,y)

42
Q

Round up and round down functions

A

ceil and floor

43
Q

What happens with integer division?

A

does not generate a fraction and throws out remainder

44
Q

What happens with floating point number and integer division?

A

floating point division does not throw out remainder like integer division

45
Q

The second operand of / and % must never be..

A

0

46
Q

What does Modulo do?

A

returns the remainder of the

47
Q

Modulo cannot handle..

A

doubles

48
Q

How do you shift a value right?

A

dividing by a power of 10, the number of 0s is the places moved

49
Q

How do you get the rightmost digits?

A

% by a power of 10, the number of 0s is how many digits

50
Q

What is type casting?

A

converting a value of a type to another
static_cast<type>(expression)</type>

to use
newVar = that above
then use newVar in expressions

or use directly when couting

51
Q

What does char store?

A

a single character in single quotes

52
Q

How is a character internally stored?

A

in ASCII, a number

53
Q

A’s number and a’s ASCII number are..

A

65 and 97

54
Q

What are escape sequences?
and what are the 5

A

used when special character would be read differently

\n - new line
\t- tab
' - single quote
" - double quotes
\ - backslash

-are used inside “ “

55
Q

What does string hold?

A

A collection of characters surround by “

56
Q

What should be enable to use strings?

A

include <string></string>

57
Q

With whitespace input you need…

A

multiple cin&raquo_space;

58
Q

To get a whole line of input…

A

getline(cin, stringVar)

59
Q

What are the 8 bit values?

A

128, 64, 32, 16, 8, 4, 2, 1
from 2 to the power of 0 increasing the power by 1 each time

60
Q

What is overflow?

A

a value type holding more than its maximum value

61
Q

What is unsigned?

A

use when we know a value will always be positive
prepend unsigned to type and varName

62
Q

When debugging…

A

fix one thing at a time and compile
computer reads from left to right
comment out
insert cout «