Chapter 2 Flashcards
(41 cards)
What do data types describe
- what values can be held by the item
- how the item is stored in memory
- what operations can be performed on the item
what are two data types that are supported by all programming languages
- Numeric
- Strings
what are the two types of constants
- numeric constant (numbers that don’t change)
- string constant (alphanumeric values) - contain numbers and characters and enclosed in question marks
declaration
a statement that provides a variable’s data type, identifier (variables name) and maybe and initial value
string variables can hold text, letters, and
special characters (punctuation etc)
type - safety prevents
assigning values of an incorrect data type
what are the rules for creating identifier’s (variable names)
- reserved keywords are not allowed
- must be one word
- must start with a letter
- should have appropriate meaning
Camel casing
variable names have a “hump” in the middle (hourlyWage)
pascal casing
variable names have the first letter in each word uppercase (HourlyWage)
Hungarian notation
form of camel casing in which the data type is part of the name (numhourlyWage)
snake casing
parts of variable names are separated by underscores (hourly_wage)
mixed case with underscores
all letters uppercase with underscores in between each letter (Hourly_Wage)
kebob case
parts of variable names are separated by dashes (hourly-wage)
assignment statement
statement that assigns variable to number (set myAnswer = myNumber * 2)
assignment operator (equal sign)
- binary operator - it requires two operands, one on each side
- right associativity - operates from right to left
- lvalue - result to the left of assignment operator
initializing a variable
giving the variable a start value
garbage
a variable’s unknown value
named constant
similar to a variable that’s assigned a value once
magic number
unnamed constant
rules of precedence
order of operations
remainder operator (modulo operator or modulus operator)
contains the remainder of a division operation
modules
subunit of programming problem
call a module
use its name to invoke the module, causing it to execute
modularization (functional decomposition)
breaking down large program into modules