Logo

Programming-Idioms

Create a function which returns the square of an integer
Implementation
VB

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another VB implementation.

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
int square(int x){
  return x*x;
}
def square(x):
    return x*x
func square(x int) int {
  return x*x
}
int square(int x){
  return x*x;
}
int square(int x){
  return x*x;
}
def square(x)
  x*x
end
function square(x) { 
	return x * x;
}
(define square
    (lambda (x)
        (* x x)))
(define (square x)
    (* x x))
sub square {
    my ($i) = @_;
    return $i ** 2;
}
fn square(x : u32) -> u32 { x * x }
int square(int x) {
   return x*x;
}
int square(int x) => x * x;
Function square(x: Integer): Integer;
Begin
  Result := x*x;
End;
square x = x^2
(defn square [x]
  (* x x))
-spec square(integer()) -> integer().
square(X) when is_integer(X) -> X * X.
@spec square(integer) :: integer
def square(x) when is_integer(x), do: x*x
declare(strict_types=1);
function square(int $x): int
{
    return $x * $x;
}

// square(4) -> 16
// square(3.4) -> Uncaught TypeError: Argument 1 passed to square() must be of the type int, float given
function square(x)
	return x*x
end
function Square (X : Integer) return Integer is
begin
   return X * X;
end Square;
int Square(int x)
{
    return x * x;
}
def square(x:Int): Int = x*x
alias fun = (in a){return a * a;};
square x = x * x
const square = (x) => x * x;
(defun square (x)
  (* x x))
let square x = x*x
module foo
  implicit none
contains
  function square(i) result(res)
    integer, intent(in) :: i
    integer :: res
    res = i * i
  end function square
end module foo
def square(x):
    return x**2
fun square(x: Int) = x * x
const square = n => n**2
int Square(int x) => (int)Math.Pow(x, 2);
const square = (number) => Math.pow(number, 2);
double Square(int value) => System.Math.Pow(value, 2);
int square(int x) {
  return x*x;
}
int square(int x){
  return x*x
}
square x = x**2
def square(x) = x*x
Function<Integer,Integer> squareFunction = x -> x * x;
Function Square(x As Integer) As Integer
    Return x * x
End Function
[:anInteger | anInteger squared]
void Square(ref int x)
{
    x = x * x;
}
private int square(int value) {
	return value * value;
}