Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Call-a-function/Little/call-a-function.little
Normal file
35
Task/Call-a-function/Little/call-a-function.little
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// Calling a function that requires no arguments
|
||||
void foo() {puts("Calling a function with no arguments");}
|
||||
foo();
|
||||
|
||||
// Calling a function with a fixed number of arguments
|
||||
abs(-36);
|
||||
|
||||
// Calling a function with optional arguments
|
||||
puts(nonewline: "nonewline is an optional argument");
|
||||
puts("\n");
|
||||
|
||||
// Calling a function with a variable number of arguments
|
||||
void var_arg_func(...args) {
|
||||
puts(length(args));
|
||||
}
|
||||
var_arg_func(1, 2);
|
||||
var_arg_func(1, 2, 3);
|
||||
|
||||
// Obtaining the return value of a function
|
||||
int s = clock("seconds"); //current time in seconds
|
||||
// Calling a function with named arguments
|
||||
// format is a named argument in Clock_format
|
||||
int str = Clock_format(s, format: "%B");
|
||||
puts(str);
|
||||
|
||||
// Stating whether arguments are passed by value or by reference
|
||||
void f(int a, int &b) { a++; b++; }
|
||||
{
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
|
||||
f(a, &b);
|
||||
puts (a);
|
||||
puts (b);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue