GATE Exam | Aptitude Questions | GATE Syllabus | GATE Result | Mock Test | GATE Preparation
0 votes
Argument: An argument is an expression which is passed to a function by its caller (or macro by its invoker) in
order for the function(or macro) to perform its task. It is an expression in the comma-separated list bound by the
parentheses in a function call expression.
Actual arguments:
The arguments that are passed in a function call are called actual arguments. These arguments are defined in
the calling function.
Formal arguments:
The formal arguments are the parameters/arguments in a function declaration. The scope of formal arguments is
local to the function definition in which they are used. Formal arguments belong to the called function. Formal
arguments are a copy of the actual arguments. A change in formal arguments would not be reflected in the
actual arguments.
Example:
#include <stdio.h>
void sum(int i, int j, int k);
/* calling function */
int main() {
      int a = 5;
      // actual arguments
      sum(3, 2 * a, a);
      return 0;
}

/* called function */
/* formal arguments*/
void sum(int i, int j, int k) {
      int s;
      s = i + j + k;
      printf("sum is %d", s);
}
Here 3,2*a,a are actual arguments and i,j,k are formal arguments.
asked in Programming by anonymous

1 Answer

0 votes

Arguments of the function are the parameter which are passed from the caller to the called function or from the command line to the main function.

Actual arguments: The arguments passed to the functions are called actual arguments.
Formal arguments: The arguments declared in the function definition is called as formal arguments.

int addition(int a, int b) 

/* a and b are formal arguments*/ 

void main()

{ int i

 .... 

i = addition(1,2); /* 1 and 2 are called actual arguments*/ 

... }

See more :- http://tech.queryhome.com/23259/argument-differentiate-between-arguments-actual-arguments

answered by abhik143

Related questions

The best answer to any question