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.

Using constants

Using constants - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Using constants

- Constants are values used in your code that never change. They can appear immediately as a literal value, or you can declare a constant expression. On line seven, you'll see four and five. These are literal values. And the sum of these values is assigned a variable a, which is then output at line eight in this printf statement. I'll build and run and you see four plus five equals nine. All is right in the universe. In this code, a parade of putchar functions output single character literals. Constants, one after the other, each specified as the argument to the function. Build and run. Hello. A string literal is any text enclosed in double quotes as shown at line five. The puts function at line seven outputs this string literal. The constant declaration in this code works like a combination of literal value and variable. Line five looks like a variable declaration and it is. Integer variable count is declared and it's…

Contents