Week 1 Flashcards
What are the 4 most common types of the C language for performing arithmetic calculations?
Char
Int
Float
Double
What is a type?
A rule that defines how to store values in memory and which operations are admissible on those values.
What is a char?
Occupies one byte and can store a small integer value, a single character, or a single symbol
What is an int?
Occupies one word and can store an integer value. In a 32 bit environment, an int occupies 4 bytes.
What is a float?
Typically occupies 4 bytes and can store a single-precision, floating point number
What is a double?
Typically occupies 8 bytes and can store a double-precision, floating point number.
What is a size specifier?
Adjusts the size of the int and double types
What are the 3 type int size specifiers?
Short
Long
Long Long
How many bits does a short int contain?
At least 16 bits
How many bits does a long int contain?
At least 32 bits
How many bits does a long long int contain?
At least 64 bits
What is a const qualifier?
Any type that can hold a constant value. A constant value cannot be changed. To qualify a type as holding a constant value, use the keyword const. A const is unmodifiable.
What are the 2 integral types? What are the 2 floating-point types?
Integral types: char, int
Floating-point types: float, double
How are integral types stored?
The integral types (char and int) are stored in equivalent binary form. Binary form represents the value stored exactly. The integral types are short, long, signed, unsigned, and plain ints.
How are floating-point types stored?
Stored as tiny and big values from being separated into three components: a sign, an exponent, and a significand.
How are characters and symbols stored?
In char types. Characters and symbols cannot be represented in binary form.
What is a value range?
The number of bytes allocated for a type that determines the range of values that the type can store
What is a declaration?
A program variable with a type. The type identifies the properties of the variable
Ex. [const] type identifier [=initial value]
How do you group multiple declarations that share the same type?
Separate the identifiers with commas.
Ex. char children, digit
int nPages,nBooks,nRooms
float cashFare, height, weight
double loan, mortgage
We may select any identifier as a variable as long as it satisfies the following name conventions:
- starts with a letter or underscore
- contains any combination of letters, digits, and underscores
- contains less than 32 characters
- is not a C reserved word