Is it better to use a macro or a function?



Is it better to use a macro or a function?..

Answer / Neha Kumari

In general, functions are preferred over macros because they offer better error checking and clarity. Macros can lead to unintended side effects and make code harder to understand and debug.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is the best way of making my program efficient?

1 Answers  


how to compare two strings without using strcmp() function??

1 Answers  


9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?

1 Answers  


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

1 Answers   Wilco,


What are terms in math?

1 Answers  


praagnovation

1 Answers  


5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.

1 Answers  


In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT

1 Answers   IBM,


What is array of structure in c programming?

1 Answers  


what is a void pointer?

2 Answers  


can we define a function in structure?

2 Answers  


what is the difference between <stdio.h> and "stdio.h"

14 Answers   Invendis, Kanbay, Mastek, MathWorks,


Categories