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.
Working with variables - C Tutorial
From the course: C Essential Training
Working with variables
- [Instructor] To assign a value to a variable, you use an assignment operator. The single equal sign is the most common. The variable sits on the left side of the equal sign. A value or expression sits on the right. In this simple statement, variable A is assigned the value 126. The value assigned a variable can be a literal value or a constant. It can be a value returned from a function. It can be the value of another variable or any C language expression. Here, four variables are declared, one for each data type. The next four statements assign each variable its appropriate data type value: character A, integer two, the floating point value 0.25, and a really big number, 2.5e6 for the double. This is expressed in E notation. Four printf statements output each of the four variables and their values. The character types are character, decimal integer, floating point, floating point. Build and run. And you can see…
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
-
-
-
-
-