The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+10 votes

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

macro	Add x, y
        Load y
        Mul x
        Store y
end macro	
  1. Variables
  2. Identifiers
  3. Actual parameters
  4. Formal parameters
asked in Compiler Design by Veteran (59.5k points) | 818 views
  • 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

2 Answers

+12 votes

ans is D

answered by Loyal (8.2k points)
edited by

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.

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

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. 




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


@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. 

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

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.

answered by Active (2.6k points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

39,848 questions
46,815 answers
59,068 users