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

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