C – Macros

What is Macro?

Macros are the names of text/ literal values/ string (constant values) or code fragment, which will expand when pre-processor processes the macro.

Pre-processor processes the macros at compile time; hence that macros replace with the corresponding code fragments.


Exercise

How you define Macro Years in sec?

 


How you define Marco using find small number?

Answer : #define MIN(x,y) ((x<y)?x:y)

Example

 


Find out MIN & MAX using MACRO in C?

Answer : #define MIN(X,Y) (X<Y ? X:Y)  or #define MAX(X,Y) (X>Y ? X:Y)


Write a macro to find the smallest number among 3 given numbers?

Answer

 


#define MAX_NUM 15   Referring to the sample above, what is MAX_NUM?

(A) MAX_NUM is a precompiler constant.

(B) MAX_NUM is a preprocessor macro.

(C) MAX_NUM is an integer variable.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

if you have any queries call us +918300026060 or WhatsApp Dismiss

0

Your Cart

%d bloggers like this: