Variables

Description
You can imagine variables is a place to store data ( number, image, etc ).
So many variables already exist, for now I will just give a little which often used.

  • int, use for storing number ( ex : 20 )
  • double, use for storing number with comma ( ex : 20.73 )
  • char, use for storing 1 unit of information ( ex : 1 or a or . )
  • string, use for storing sequence of char (ex : a or aaaa)
  • bool, use for storing true or false.
How to Use It

Put the type variable, and give it a name, don't for to always put semicolon (;).
Always use name which easily recognizable. 


int length;


If you have many variables with same type, you can put (,).

int length , width;

You can directly store the the value want.

int length = 2;

You can directly store the the value from other variable.

int length = 2;
int width = length;

You can also store the the value from current variable.

int length = 2;
length = length + 5;

The value of length will change to 7.


Komentar