What is Argument in Programming?

An argument is a statement that explains why something should happen. When applied to programming, an argument can take the form of a function call, or it could be in the form of data passed into a function. Arguments are often used as input for functions so that they will execute properly.

An argument can also be shortened to arg, and it is a data value that is passed by the user into a command, routine, or function.

Example in Python

The following code will print “Hello World” to the console. To do this, there is one argument that is passed into a function called `print`. Within the brackets of the call to `print`, it states what should be printed which is simply ‘hello’.

//print out a string
print('Hello World')

Example in PHP

The example shows how to use a function to display a number as float with 2 decimal.

function f($source, $decimal = 2){        
    return number_format(floatval($source), $decimal, '.', ',');
}

echo f('1000'); //1000.00

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close