Skip to content

Latest commit

 

History

History
171 lines (131 loc) · 1.83 KB

function-defination.md

File metadata and controls

171 lines (131 loc) · 1.83 KB

Function Defination and Call

C

// define a function
void some_function() {
    // some logic
}

// call the function
some_function();

C#

public class Main {
    public static void Main(String[] args) {
        // call the function
        SomeFunction();
    }

    // define a function
    public static void SomeFunction() {
        // logic
    }
}

C++

// define a function
void someFunction() {
    // some logic
}

// call the function
someFunction();

Go

package main

func main() {
    // call the function
    someFunction();
}

// define a function
func someFunction() {
    // logic
}

Java

public class Main {
    public static void main(String[] args) {
        // call the function
        someFunction();
    }

    // define a function
    public static void someFunction() {
        // logic
    }
}

JavaScript

// define a function
function someFunction() {
    // logic
}

// call the function
someFunction();

Kotlin

// define a function
fun someFunction() {
    // logic
}

// call the function
someFunction()

Perl

# define a function
sub some_function  {
    # logic
}

# call the function
some_function();

PHP

<?php
// define a function
function someFunction()
{
    // logic
}

// call the function
someFunction();
?>

Python

# define a function
def someFunction:
  # logic

# call the function
someFunction

Ruby

# define a function
def someFunction()
    # logic
end

# call the function
someFunction

Scala

// define a function
def someFunction():Unit = {
  println("Hello, world")
}

// call the function
someFunction

Swift

// define a function
func someFunction() {
    // logic
}

// call the function
someFunction()