Question & Additional Information
 
What is a macro, and how do you use it?
Add to My IQ
 

 | 
Inappropriate
Answer Title
Answer
A macro is a preprocessor directive that provides a mechanism for token replacement in your source code. Macros are created by using the #define statement.  Here is an example of a macro: Macros can also utilize special operators such as the stringizing operator (#) and the concatenation operator (##).The stringizing operator can be used to convert macro parameters to quoted strings, as in the following example: #define DEBUG_VALUE(v) printf(#v " is equal to %d.n", v)
In this program, we can check the value of a variable by invoking the DEBUG_VALUE macro: int x = 20; DEBUG_VALUE(x);  The preceding code prints "x is equal to 20." on-screen. This example shows that the stringizing operator used with macros can be a very handy debugging tool.
Question Tag Title
Tags
Question Asked At Title
Asked At
None
Question Job Title
Job Titles


Check out our newest job listings!

Post a Job! $49 for 60 days



Your Name:
Add your comment text
 
Related Questions
Related Questions
Flag this interview question as inappropriate Inappropriate
See Answer

If you perform a task repeatedly in Microsoft Excel, you can automate the task with a macro. A macro is a series of commands and functions (function: A prewritten formula that takes a value or values, performs an operation, and returns a value or values. Use functions to simplify and shorten formulas on a worksheet, especially those that perform lengthy or complex calculat that are stored in a Microsoft Visual Basic module and can be run whenever you need to perform the task. For example, if you often enter long text strings in cells, you can create a macro to format those cells so that the text wraps.

Create Date
:
Tuesday, November 25, 2008
Tags
:
None
Asked At
:
None
Job Positions
:
None
Click here to improve the Interview Question, Answer and other fields.
Comments (1) :
1.
bbfromdc123
Saturday, November 29, 2008 11:53 AM
I know I know I know...
Flag this interview question as inappropriate Inappropriate
See Answer
Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro.
Create Date
:
Sunday, April 27, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
Flag this interview question as inappropriate Inappropriate
See Answer
Yes, I do. A macro is intended to help automate some of the redundant computations and processes by recording it under a macro name. An example would be a s series of formulas that you record and assign under one macro. All you need to do is to call on that macro when needed.
Create Date
:
Saturday, April 12, 2008
Asked At
:
None
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
Flag this interview question as inappropriate Inappropriate
See Answer
#define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives preprocessor warning. Why?

in this case the cat(x,y) is the macro which is defined by using the preprocessor directive , this will be substituted only at the place where it is called in this example it happens like this

cat(1,2)##3 which will once again become 1##2##3
here if we use ## in between we can join or concatenat only two variables that why it gives a preprocessor warning
Create Date
:
Sunday, March 16, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (1) :
1.
dk
Sunday, March 16, 2008 9:37 PM
is this really an interview question..?
why complicate ?
Flag this interview question as inappropriate Inappropriate
See Answer
Templates allow to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until certain point they fulfill the functionality of a macro. Its prototype is any of the two following ones:  template <class indetifier> function_declaration; template <typename indetifier> function_declaration;the only difference between both prototypes is the use of keyword class or typename, its use is indistinct since both expressions have exactly the same meaning and behave exactly the same way.
Create Date
:
Saturday, March 15, 2008
Tags
:
Asked At
:
None
Job Positions
:
Click here to improve the Interview Question, Answer and other fields.
Comments (0) :
Goto add your comment on the Question 
 
• More Related Questions: 
Suggestions & Comments




Share Your Interview Questions
Ask Interview Questions
View Unanswered Questions





Advertise on this site