what is differnence b/w macro & functions



what is differnence b/w macro & functions..

Answer / babitha

macro: one line function;not having any return type and
argument so it would not report error even if any
misbehaves in fnction;not having return statement;
macros would be replaced by that functions/value where ever
macro name presents;if we need any later change in funcions
then modifing only at macro is neccssary, sicne it is
replacing wherever macro name presents.

functions:we would recieve error if the function call and
function prototypes are mismatch;xplicitly it should have
one return statement if the retrun type of fucntion is
aother than void;control from main function would jump to
function defintion of called fucntion if that function is
called rather than replacing the function;it may have moe
than one line function.If we want later change i fucntion
execution,then we need to modify on function prototype(if
modified),fucntion defintion and whereever that function is
called.

Is This Answer Correct ?    4 Yes 2 No

Post New Answer

More C Interview Questions

Can you please explain the difference between exit() and _exit() function?

0 Answers  


How we can write a value to an address using macro..?

0 Answers   Tata Elxsi,


can we declare a function inside the structure? ex: struct book { int pages; float price; int library(int,float); }b; is the above declaration correct? as it has function declaration?

2 Answers  


How can you find the exact size of a data type in c?

0 Answers  


code for selection sort?

1 Answers  






What is the difference between text and binary modes?

0 Answers  


Is null always defined as 0(zero)?

0 Answers  


How to add two numbers without using semicolon n c????

3 Answers  


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

0 Answers   KPIT,


What are header files in c?

0 Answers  


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

2 Answers   Ignou,


what is the similarities between. system call and library function?

1 Answers   Wipro,


Categories