Skip to content
KnowledgeCity

C Variables and Constants

Learn how to implement the different C data types into your code
Preview the first lesson free — get full access to all 4 lessons.
Course: On-Demand
Beginner Provider Mike McMillan  4 Lessons ·  17m  in Arabic, German, English, Spanish, French, Portuguese, Chinese 

Course Description

In this Variables and Constants course, we’ll cover the different data types C uses to work with numbers and text. These lessons will cover the fundamental data types for storing numbers, characters, and strings, including Int for whole numbers, Float for single-precision floating-point numbers, and Double for double-precision floating-point numbers. We’ll also explain Char, the data type C uses for individual alphabetic characters, which is stored as an integer value to make the language more efficient—C does not have a string type, but instead stores strings as arrays of characters.

These lessons also discuss why C doesn’t have a special constant for true or false values. C was designed to be an efficient programming language, and not having a dedicated Boolean type allows programs to run much more efficiently. This often causes confusion for programmers experienced with more modern languages, as these languages usually have a Boolean type for true and false values.

What You'll Learn

  • Create code using the three C numeric data types: Int for whole numbers, Float for single-precision floating-point numbers, and Double for double-precision floating-point numbers
  • Explain how C uses the Char data type to store individual character values as integer values
  • Understand how Boolean data is represented in C and why C has no dedicated true/false constant
  • Declare and assign values to variables, and initialize new variables
  • Declare and use constants in C
  • Write arithmetic statements in C

Key Takeaways

  • C uses Int for whole numbers, Float for single-precision floating-point numbers, and Double for double-precision floating-point numbers.
  • C stores the Char data type as an integer value to make the language more efficient, and it does not have a string type, instead storing strings as arrays of characters.
  • C does not include a dedicated Boolean type for true and false values, which allows programs to run more efficiently.
  • The absence of a Boolean type often confuses programmers experienced with more modern languages that usually have one.
  • The course covers declaring and assigning values to variables, initializing new variables, declaring and using constants, and writing arithmetic statements.

Frequently Asked Questions

What does this course cover?

It covers the different data types C uses to work with numbers and text, including the fundamental data types for storing numbers, characters, and strings: Int, Float, Double, and Char. It also explains why C does not have a special constant for true or false values.

Which numeric data types are taught in this course?

The course covers the three C numeric data types: Int for whole numbers, Float for single-precision floating-point numbers, and Double for double-precision floating-point numbers.

How does C handle characters and strings according to this course?

C uses the Char data type for individual alphabetic characters, stored as an integer value to make the language more efficient. C does not have a string type and instead stores strings as arrays of characters.

Why does C not have a Boolean type?

C was designed to be an efficient programming language, and not having a dedicated Boolean type for true and false values allows programs to run much more efficiently.

What lessons are included in this course?

The lessons are: Declaring and Assigning Values to Variables; Initializing New Variables; Declaring and Using Constants; and Arithmetic Statements.