4- types, expressions, more on assignment Flashcards
int
whole numbers
double
numbers with fractions (called floating point numbers)
char
single character ex: ‘a’
bool
(short for boolean) is used for branching and looping statements
a boolean variable can have only two values true or false
Literal constants
is an explicitly stated value
examples: 23 34.4 ’a’ true
a literal constant has value and type
Named constant
named constant gives a name to a value; have to be declared:
const int windowCount = 5;
const double taxRate = 9.8;
style:
use named constants rather than literal constants
use named constants rather than variables
Expression
mechanism of calculating new values
Expression evaluation
computing the value of an expression during program execution
Simple expression
literal constant, named constant, variable
Complex expression
consists of operands joined by operators
Operator
order to computer to carry out a task,
in expression, computes new value based on operands
has an associated symbol
Operand
(sub) expression
arity
number of operands the operator uses
Binary operator
two operands
Unary operator
one operand