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

Working with variables - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

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…

Contents