Show Menu
Cheatography

Constantly updating basic CheatSheet for C Cheat Sheet (DRAFT) by

This is a cheatsheet for c language

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Variable, Const and Declar­ation

Variable
syntax : datatype variab­leName = value
int myVariable = 100;


Const
syntax : storag­etype datatype variab­leName = value
const int myVariable = 100;

syntax : #define variab­leName value
#define myVariable 100;


Declar­ation and Initia­liz­ation
syntax : storag­etype datatype variab­leName = value
int myVariable = 110;

OR
syntax : storag­etype datatype variab­leName
int a, b, c

syntax : variab­leName = value
a = c = 10;

b = 20;
Declar­ation and Initia­liz­ation can be done at the same time or at different time, but you must declare first and is usually done at the top and then initialize later. But it was an old practice, now there is no need to declare at top at first and then initialize
 

Datatypes tree

 

Datatypes

Types
Bits
Minimal Range
Char
8
-127 to 127
Unsigned Char
8
0 to 255
Signed Char
8
-127 to 127
Int
16 or 32
-32,767 to 32,767
Unsigned Int
16 or 32
0 to 65,535
Signed Int
16 or 32
-32,767 to 32,767
Short Int
16
-32,767 to 32,767
Unsigned Short Int
16
0 to 65,535
Signed Short Int
16
-32,767 to 32,767
Long Int
32
-2,147­,48­3,647 to +
Long Long Int
64
-(263-1) to 263-1
Signed Long Int
32
-2,147­,48­3,647 to +
Unsigned Long Int
32
0 to 4,294,­967,295
Unsigned Long Long Int
64
264-1
Float
32
IE-37 to IE+37
Double
64
IE-37 to IE+37
Long Double
80
IE-37 to IE+37