From the course: C Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using constants
- Constants are values used in your code that never change. They can appear immediately as a literal value, or you can declare a constant expression. On line seven, you'll see four and five. These are literal values. And the sum of these values is assigned a variable a, which is then output at line eight in this printf statement. I'll build and run and you see four plus five equals nine. All is right in the universe. In this code, a parade of putchar functions output single character literals. Constants, one after the other, each specified as the argument to the function. Build and run. Hello. A string literal is any text enclosed in double quotes as shown at line five. The puts function at line seven outputs this string literal. The constant declaration in this code works like a combination of literal value and variable. Line five looks like a variable declaration and it is. Integer variable count is declared and it's…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Understanding C language data types3m 4s
-
(Locked)
Declaring variables2m 49s
-
(Locked)
Working with variables2m 55s
-
(Locked)
Exploring the printf() function3m 4s
-
(Locked)
Using constants2m 53s
-
(Locked)
Challenge: Make variables and constants47s
-
Solution: Make variables and constants1m
-
(Locked)
Understanding variable scope3m 8s
-
(Locked)
Making new data types3m 24s
-
(Locked)
Specifying characters and strings3m 17s
-
(Locked)
Specifying integers and real numbers4m 14s
-
(Locked)
Typecasting a variable3m 11s
-
(Locked)
Challenge: Basic I/O1m 10s
-
(Locked)
Solution: Basic I/O1m 35s
-
-
-
-
-