belongs to collection: C Preprocessors Programs
As we have discussed in the last post (how to use printf in function like macro?) that we can use printf() in Macros.
Here, we have to define a Macro that will accept an argument and print it by using printf() function.
Macro definition:
#define PRINT(val) (printf("value is: %d\n",val))
Example:
#include <stdio.h> #define PRINT(val) (printf("value is: %d\n",val)) //Main code int main(){ PRINT(10); PRINT(100); PRINT(-12); PRINT(0); return 0; }
Output:
value is: 10 value is: 100 value is: -12 value is: 0
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Example:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer