An argument is a value passed to a function when the function is called. Whenever any function is called during the execution of the program there are some values passed with the function. These values are called arguments. An argument when passed with a function replaces with those variables which were used during the function definition and the function is then executed with these values. Let’s look at some examples for easy understanding:
SUM IS: 7
In the above example in the function the variable x and y are the arguments
A parameter is a variable used to define a particular value during a function definition. Whenever we define a function we introduce our compiler with some variables that are being used in the running of that function. These variables are often termed as Parameters. The parameters and arguments mostly have the same value but theoretically, are different from each other.
SUM IS: 7
In the above example in the function the variable a and b are the parameters
Difference between an Argument and a Parameter
|When a function is called, the values that are passed in the call are called arguments.||The values which are written at the time of the function prototype and the definition of the function.|
|These are used in function call statement to send value from the calling function to the called function.||These are used in function header of the called function to receive the value from the arguments.|
|During the time of call each argument is always assigned to the parameter in the function definition.||Parameters are local variables which are assigned value of the arguments when the function is called|
|They are also called Actual Parameters||They are also called Formal Parameters|
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Argument and Parameter in C/C++ with Examples
- Parameter Passing Techniques in Java with Examples
- Command Line Argument in Scala
- Golang program that uses func with variable argument list
- HTML | DOM Parameter Object
- How to create default function parameter in PHP?
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java Deprecated API Scanner tool (jdepscan) in Java 9 with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.LinkedList.offer(), offerFirst(), offerLast() in Java
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.LinkedList.peek() , peekfirst(), peeklast() in Java
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java lang.Long.reverse() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ManasChhabra2