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.
C Data Types | |
---|---|
Type | C Standard |
int | All |
long int | All |
long long int | All |
short int | All |
unsigned | All |
float | All |
double | All |
long double | All |
char ... |
Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.