Search
Create
Log in
Sign up
Log in
Sign up
CS 1A quiz 1
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Terms in this set (74)
from what language did C++ originate?
B --> C --> C++
input device
device that allows the outside world to communicate information to the computer (mouse, keyboard, etc.)
output device
device that allows the computer to communicate information to the outside world (monitor, printer, speaker, etc.)
main memory
a list of addressable numbered memory locations that the computer can operate on; used to store and retrieve from the memory location
memory location
single indivisible portion of memory that holds data
address
the number that identifies a memory location (only 1 address per memory location)
program
a sequence of instructions for a computer to follow
software
a series of programs
operating system
used by programmers; allocates computer resources, launches other programs and makes sure they work properly
libraries
collection of routines to be used in other programs (input/output, math, etc.)
application
to be used by end-users
data
input to the program
natural language
language used by humans; too ambiguous for computers
high-level language
close to natural that is understood by humans (C++)
machine language
list of instructions in binary format that a computer understands (smaller the number, faster & more efficient) (0s and 1s used because using more would be too expensive)
compiler
a system program that translates high-level language into low-level language
linker
combines the object code for program pieces with the object code that the compiler produced from the C++ program
code
set of instructions for a computer to follow (synonymous to a program)
source code
in high-level language
object code
in low-level language (machine language)
executable code
code that can be run on a computer
Rules of programming (3 s's)
syntax, semantics, style
syntax rules
principles of constructing/structuring the program
legal program
complies with syntactic rules
illegal program
does not follow syntactic rules
semantic rules
reaming of the program parts
style
non-syntactic rules of programming
variable
named memory location
variable value
data stored inside a variable (variable always has value); compiler removes the variable name and assigns a memory location
identifiers
name of a variable or any other named construct; must start with either a letter or underscore (any other can be letter, underscore, or number)
identifier style
should be long enough to understand but short enough to be reasonable to type (standard abbreviations)
2 styles of identifiers
C-Style, and Camel Case
C-Style
terse, abbreviations, underscore to separate words, no capital letters
Camel Case
capitalize first letter of every word, no underscores (more modern)
keyword
an identifier recognized already in C++
variable type
kind of data stored in the variable
variable declaration
intro of the name to computer (a statement); every variable in C++ must be declared before use; should be declared as close to its use as possible, but before its use (arbitrary until assigned);
variable declaration always contains....
identifier and value
assignment statement
an order to the computer to set the value of the variable on the left side of the equal sign to what is written on the left
stream
a sequence of data to be processed
input stream
goes into the program
output stream
generated BY the program
cout
console output (an identifier)
insertion operator
<< inserts data into output stream
escape sequence
"\n" ends line on console (synonymous with "endl;"
cin
console input (an identifier) used to give variable user-input values (from the keyboard) ("using std::cin;)
extraction operator
>>
input token
sequence of characters separated by white space (spaces, tabs, new lines)
int (integers)
whole numbers
double
numbers with fractions or decimals (floating point numbers)
character type
char; stores a single character; declared char VarName
boolean type
bool used for branching and looping statements; can only be true or false
literal constants
has value and type; an explicitly stated value
named constant
gives a name to a value; has to be declared
type compatibility
you cannot store a variable of one type in a variable of another type
expression
a mechanism of calculating new values (has value and type)
expression evaluation
computing the value of the expression
complex expression
consists of operands joined by operators
compound assignment
joins assignment with another operator
2 kinds of code
terse and sparse (terse preferred)
initialization
explicitly assigning initial value to a variable
block
a list of statements in curly brackets
variable scope
area in program where a variable can be used; accessing a variable outside of the block is an error
conditional constructs
provide the ability to alter the course of statement execution (if-statement, switch-statement, conditional statement)
nested if
one if is the body or inside the block of another (inner if and outer if); may be more than 2 if's deep
multiway if-statement
ability to carry out actions depending on the value of an expression; glues if-else statements together
switch statement
implements multiway branches; has "cases" that alter the cout depending on the cin
break statement
terminates the switch statement, execution continues with a statement following switch-block
programming idiom
common way of accomplishing a simple task by swapping values of 2 variables with a 3rd (milk and water glass analogy)
conditional operator
used as an abbreviated form of branching
conditional assignment statement
conditional operator is used to assign value to a variable
unary operators
a single operand (takes precedence)
binary operator
two operands
ternary operator
accepts 2 operands
;