O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Proper Variable Syntax

The overwhelming majority of data you'll work with will be in the form of variables (as opposed to constants, which you'll also learn about at the end of this chapter). To use a variable, you must first declare it—in other words, you state that a variable with a specific name will be of a certain type. The declaration statement looks like this:

					datatype variablename;

For example:

int age;
float cost;
char answer;

The different types are listed in Table 2.1, along with what version of C they are allowed in.

Table 2.1. The basic variable types for use in the C language and what standard they fall under.
C Data Types
TypeC Standard
intAll
long intAll
long long intAll
short intAll
unsignedAll
floatAll
doubleAll
long doubleAll
char ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required