From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Using constants - C Tutorial
From the course: Complete Guide to C Programming Foundations
Using constants
- [Instructor] Constants are values that never change. They can appear immediately as a literal value, or you can declare a constant expression. In this code on line seven, you see literal constants four and five. The result of adding these values is assigned to integer variable A. The printf statement outputs the value of variable A. And the computer knows that four and five equal nine. This is good. In this code, literal character constants appear inside a parade of putchar functions. Hello. Here you see a string literal, text enclosed in double quotes. The puts function at line five outputs the string literal. Greetings computer. Here you see a constant declaration at line five. The const keyword classifies the integer identifier count as a constant value assigned four. Creating a constant in this manner requires that it be initialized to a value just like this in a single statement. The compiler issues an error if you attempt to change the value of a constant elsewhere in the…
Contents
-
-
-
-
Understanding C language data types3m 17s
-
(Locked)
Declaring variables2m 53s
-
(Locked)
Working with variables3m 4s
-
(Locked)
Exploring the printf() function3m 48s
-
(Locked)
Using constants2m 58s
-
Challenge: Making variables and constants53s
-
(Locked)
Solution: Making variables and constants1m 16s
-
(Locked)
Understanding variable scope3m 35s
-
(Locked)
Making new data types3m 25s
-
(Locked)
Specifying characters and strings3m 17s
-
(Locked)
Specifying integers and real numbers3m 55s
-
(Locked)
Typecasting a variable2m 20s
-
(Locked)
Chapter challenge: Adding variables and constants1m 10s
-
(Locked)
Chapter solution: Adding variables and constants2m 7s
-
-
-
-
-
-
-
-
-
-