From the course: C Essential Training
Solution: Make variables and constants - C Tutorial
From the course: C Essential Training
Solution: Make variables and constants
(upbeat music) - [Instructor] Here is how I wrote my solution. On line 5, I create integer variable a, and I immediately assign it the value 16. On line 6, I create the constant character b, which must be immediately assigned to a character. I chose Z for a constant. This is the only way to construct the assignment. You cannot have a statement later that modifies constant b. Build and run, and here's the results. In this variation, I assigned the value of 16 to variable a and its own statement at line 8. This solution is also acceptable, and I hope you devised something similar. Remember, constants are declared by using the const keyword as shown here at line 6, and they must be assigned a value immediately in the same statement.
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
-
-
-
-
-