C TutorialLesson 8Free preview
C Data Types
This lesson is part of C · All levels
Summary
The data type determines the type of value a variable can store and the size of the memory it uses. C provides built-in types such as int (integer), float and double (decimal), char (one character), as well as short and long for variations in the width of integers. The right type selection is essential to save memory and not lose accuracy. The size of each type can vary between platforms, but generally int uses 4 bytes.
Key points
- Int for integers, float/double for decimal numbers, char for one character
- Double has higher precision than float
- The unsigned type only keeps the nonnegative value so the positive range is larger.
- The sizeof operator displays the size of a type or variable in bytes
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.