Next: C type modifiers Up: Variables Previous: Variables

C types

The basic types available in C are

   char
   int
   float
   double

There is also a special ennumeration type for integer variables which are only allowed a limited range of values, which you have to list. For example:

   enum boolean { NO, YES } ;

This allows you to declare variables with

   enum boolean answer;

and to assign values:

   answer= YES;

In fact the effect is that the list is simply numbered sequentially from 0, (NO= 0; YES= 1). This can be modified:

enum months { JAN= 1, FEB, MAR, APR ,MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC }

The ennumeration continues sequentially from the last one to be given a value.



Next: C type modifiers Up: Variables Previous: Variables


maspjw@
Tue Sep 27 15:29:34 BST 1994