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
long intAll
long long intAll
short intAll
long doubleAll
char ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.