Kind of value
Integer, character, decimal value, or another form of data.
A data type tells C what kind of value is being stored and how that value should be interpreted.
Type → Name → Value
Integer, character, decimal value, or another form of data.
The implementation chooses storage according to the type.
The type influences which operations and interpretations are meaningful.
Stores a character value such as 'A'. It is also an integer type in C.
| Data type | printf() | scanf() |
|---|---|---|
char | %c | %c |
int | %d | %d |
unsigned int | %u | %u |
short int | %hd | %hd |
long int | %ld | %ld |
long long int | %lld | %lld |
float | %f | %f |
double | %f | %lf |
char name[] | %s | %s |
For scanf()
| Bits | Unsigned range | Signed range |
|---|---|---|
| 4 | 0 to 15 | −8 to 7 |
| 8 | 0 to 255 | −128 to 127 |
| 16 | 0 to 65,535 | −32,768 to 32,767 |
| 32 | 0 to 4,294,967,295 | −2,147,483,648 to 2,147,483,647 |
int to have the same number of bits on every implementation.
Students calculate first, then click the result panel.
int in bytes.int.int.unsigned int.Requests an integer type no wider than ordinary int.
Requests an integer type with at least the range of int.
Unsigned integer types represent only non-negative values.
Stores a fixed number of elements of the same type.
Stores an address associated with an object or function type.
Describes a function's return type and parameter types.
Select a named value.
A variable may store a value that changes. A constant represents a value that should not change.
Introduces the variable name and its data type.
Gives the variable its first value when it is created.
Stores a new value in an existing modifiable variable.
A whole-number literal.
A numeric literal with a fractional form.
One character written in single quotes.
A sequence of characters in double quotes.
Explains what kind of value is stored and how C interprets it.
A named object whose stored value may change during execution.
A value or symbolic form intended not to change.