自訂與內建函式
#include "/usr/include/stdio.h"
int max(int a, int b) {
int c;
if (a>b) c=a;
else c=b;
return c;
}
main(void)
{
int x=20,y=30;
int d=max(x,y);
printf("The max number is: %d\n",d);
}
php
#!/usr/bin/php
<?php
function max_num($a,$b) {
if ($a>$b) {
$c=$a;
}
else {
$c=$b;
}
return $c;
}
echo max_num(3,2)."\n";
?>
shell script
#!/bin/bash
max_num() {
if [ $1 -gt $2 ]
then
c=$1
else
c=$2
fi
return $(($c))
}
max_num 10 20
echo $c