From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Working with variables - C Tutorial
From the course: Complete Guide to C Programming Foundations
Working with variables
- [Instructor] To assign a value to a variable, you use an assignment operator, the single = is the most common. The variable sits on the left side of the =. A value or expression sits on the right. In this simple statement, variable A is assigned the value 126. The value assigned from 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 of value of the proper data type, character A, integer two, real number 0.25, and real number 2.5 million, which is expressed here in e-notation. Four printf statements output each value within each formatting string. A specific placeholder represents the different data types, character, decimal, integer, and the two floating point values. Run to see the output. You can see how the double precision output for variable D is expressed with…
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
-
-
-
-
-
-
-
-
-
-