Types ๐ค#
A type in C is a representation of a certain โtypeโ of data. Every value in C has a โtype.โ Here are the list of the 3 common types we will be dealing with:
Name |
Description |
Examples |
---|---|---|
Integer |
Represents an integer. |
0, -10, 2, 150, -349 |
Float |
Represents a decimal number, with at most 7-8 decimal places. |
0, -10.43, 2.23420, 150.493, -349, -4230.340 |
Character |
Represents a single symbol. |
โaโ, โDโ, โ1โ, โ#โ, โ^โ, โ%โ, โ&โ |
String |
Represents a sequence of characters. |
โhello world!โ, โthe quick brown foxโ |
More on Strings#
As you learned in Lesson 1, a sequence of characters is called a string. Although many programming languages have a dedicated string type, C does not.
Note
The name โstringโ comes from using the word โstringโ to describe lists of objects, such โa string of beadsโ. For the string type, it means โa string of charactersโ.
Tasks ๐ฏ#
What type can be used to represent 5820?
Solution โ
Integer
What type can be used to represent the letter C?
Solution โ
Character
What type can be used to represent the phrase, โthe quick brown fox jumps over the lazy dogโ?
Solution โ
String