994 views

What are $x$ and $y$ in the following macro definition?

macro	Add x, y
Mul x
Store y
end macro	
1. Variables
2. Identifiers
3. Actual parameters
4. Formal parameters
+4
• formal parameter — the identifier used in a method to stand for the value that is passed into the method by a caller.
• For example, amount is a formal parameter of processDeposit
• actual parameter — the actual value that is passed into the method by a caller.
• For example, the 200 used when processDeposit is called is an actual parameter.
• actual parameters are often called arguments

An identifier is a name used for a class, a variable, a method, or a parameter

Source of informtion

ans is D

edited by
+13

Why is it Formal Parameter and not Actual Parameter ? Because in case of macros there is no need to pass the variables.The MACRO code itself will be pasted in the program.And the computation will occur on the actual copies of and y.

0
@bikram sir, is answer A or D ? in gateoverflow pdf both are given as answer
+5

The macro definition is made with formal parameters. When the macro call is placed, the formal parameters will be substituted with actual parameters from the call and the call will be replaced with the macro body having appropriate actual parameters.

0

in macro definition these are formal but when replacement done in the actual code then it is actual parameters ,right?

0

@rahul it is formal  parameters from preprocessor point of view. after preprocessing, there won’t be any such distinction. pic is of section “C preprocessor “ from Dennis ritchie- C programming language.

0
yes true. from macro it is formal parameters.I was thinking after the preprocessor but then it is no longer formal.Thanks:)

A parameter or argument is data which is taken as input or considered as additional information by the function for further processing. There are two types of parameters or arguments. The parameters which are passed in the function call are known as actual parameters or actual arguments. The parameters which are received by the called function are known as formal parameters or formal arguments. Example is shown below:

In the above example, x and y are known as actual parameters and a and bare known as formal parameters.

1
2