Data Types in C

Each variable has an associated data type in C programming. C language supports both signed and unsigned literals and requires different amounts of memory.

Basic Data Types

Type Specifier Description
int Stores an integer number
long int Stores a long integer numbers
unsigned int Stores an unsigned integer numbers
char Store a character
unsigned char Store a unsigned character
float Stores a floating number
Double Stores a double floating number
long double Stores a long double floating number

Variable

Variable is a location in computer memory where data is temporary stored OR saved.

How to use

e.g: int RollNumber = 13;

Explanation
int is Data Type of variable
RollNumber is Name of variable
13 is Value of variable

Another Example

e.g: float floatingVariable = 5.67;

Explanation
float is Data Type of variable
floatingVariable is Name of variable
5.67 is Value of variable

Difference between variable Declaration, Definition and Initialization
Variable Declaration:

int MyVariable;

Variable Definition:

MyVariable = 56;

Variable Initialization:

int MyVariable = 56;


Printf Format Specifiers
Specifier Use
%c character
%u unsigned decimal
%n Nothing printed
%d decimal
%f floating number
%i integer
%X Unsigned hexadecimal
%p Pointer address
%o Octal number
%s string

Printf Characters
Characters Use for
\t Tab
\v Vertical tab
\b Backspace
\n Goto new line
\\ Backslash
\a Audible alert
\f form feed
\r Carriage return