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