Introduction to C Programming
Basic Data Types

Summary Sheet

Fundamentals of Data Storage

Integral Types

int

long int

long long int

short int

unsigned ints

char

Integral Constants

Integer Overflow

Floating Point Types

float

double

long double

Floating point constants

 

Characters

Character Constants

Escape Sequence

Meaning

\a
alarm ( bell )
\b
Backspace
\f
Form feed ( clears screen )
\n
New line
\r
Carriage return
\t
Horizontal tab
\v
Vertical tab
\\
Backslash
\?
Question mark
\'
Single quote
\"
Double quote
\0
Numerical zero ( null byte )

Character Arithmetic

char letter = 'G', lower, upper;

// Presume lower has been given a value somehow

letter = letter + 3;     // letter has now been changed from 'G' to 'J'

if( lower >= 'a' && lower <= 'z' )    // If lower is a lower-case letter
	upper = lower + ( 'A' - 'a' )	  // Convert it to upper-case by adding an offset

Character Strings

Special Types

Type Conversions

Implicit

Constants Exercise

Variables ( Covered Previously in Basic Structure of a C Program )

Type-Related Functions and Concepts ( Advanced, Optional )

Enumerated Types ( Advanced, Optional )

     enum errorType { none = 0, minor1 = 1, minor2, major1 = 100, major2, fatal1 = 1000 };