Core Features
Variables
Learns about Cambo variables
Declaration & Initialization
Below are the basic syntax to declare and initialize a variable.
syntax
type identifier;
syntax
identifier = value;
syntax
type identifier = value;
If a variable is declared without initialization, it will be automatically set to zero or an equivalent value, such as
\0, null, etc.- Declaring a variable means creating a variable by specifying its name and type, without assigning a value to it,
int number;. - Initializing a variable means assigning a value to a varible for the first time,
number = 3;
Basic types
In Cambo, there are many different kinds of data types, however here are some basic ones:
- int : stores integers, whole number, such as 1975 or -1975.
- float: stores floating point numbers, with decimals, such as 19.70 or - 19.70.
- bool: stores values with two state: true or false.
- char: stores single characters, such as 'A', or 'a', value
A conditional statement is programming construct that executes different code depending on whether a gs are surrounded by single quote
''. - string: stores text, such as "Khmer", strings are surrounded by double quote
"".
string is not a originally a primitive data type, it's a built-in struct in Cambo.
Example
int number = 12;
number = 99; # assign a new value
Other types:
float num = 3.14;
bool running = false;
char = 'A';
string = "hello, world!";