From the course: C Essential Training
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Declaring variables
- [Instructor] A variable is a storage container you use in your code that hold things that can change. The variable must be declared before it's used. It's given a data type and a name. It can also be initialized to a given value though this assignment can come later. Variables are declared in a statement typically at the top of the function as shown here in the main function at lines five through seven. So character variable c, integer variable i, and float variable f. You can also declare a variable elsewhere in the code. So down at line 17, double d is declared. Providing that the variable is declared before it's used, you're good. Using a variable that's not declared generates a warning. So back down at line 17, I'm going to comment out this line. Here we go. It's disabled. I'm going to save the change and build, and check the build messages tab. You see that variable d is used, but it's undeclared. A…
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
-
Declaring variables2m 49s
-
Working with variables2m 55s
-
Exploring the printf() function3m 4s
-
Using constants2m 53s
-
Challenge: Make variables and constants47s
-
Solution: Make variables and constants1m
-
Understanding variable scope3m 8s
-
Making new data types3m 24s
-
Specifying characters and strings3m 17s
-
Specifying integers and real numbers4m 14s
-
Typecasting a variable3m 11s
-
Challenge: Basic I/O1m 10s
-
Solution: Basic I/O1m 35s
-
-
-
-
-