Functions
Defining Functions
We define a function using the ndondomeko
keyword. The function name is followed by the parameter list in parentheses. The function body is enclosed in curly braces.
nambala phatikiza(yambi, chiwiri) {
}
A function can return a value using the bweza
keyword.
nambala phatikiza(yambi, chiwiri) {
bweza yamba + chiwiri;
}
Calling Functions
Once a function is defined, it can be called by using the function name followed by the required arguments in parentheses.
phatikiza(1, 2);
If the function returns a value, the return value can be assigned to a variable.
nambala yamba = phatikiza(1, 2);