How you can write multiline macro in C programming language. We usually outline macros that spans over single line. Nevertheless there exists conditions while you wish to outline a macro that spans over a number of line.
On this put up I’ll clarify methods to write a multiline macro in C language. So allow us to get began.
Required data
Fundamental C programming, Preprocessor directives, Macros
In the course of the course of macros programming workout routines, we learnt fundamentals of macros. How you can outline and undefine a macro. On this put up we are going to proceed forward with macro and can study to outline multiline macro.
For many of the instances macros are candy and quick, prolonged upto single line. Nevertheless, generally we outline difficult macros that spans over a number of strains. Defining these macros in single line will lose code readability, therefore we outline multiline macro .
Learn extra How you can print supply code of a program?
To outline a multiline macro append slash on the finish of every line of a macro.
Program to outline multiline macro
/**
* C program to create multiline macro
*/
#embrace <stdio.h>
// Macro to test and print even odd quantity
#outline EVEN_ODD(num)
if (num & 1)
printf("%d is oddn", num);
else
printf("%d is evenn", num);
int foremost()
{
int num;
// Enter quantity from person
printf("Enter any quantity: ");
scanf("%d", &num);
EVEN_ODD(num);
return 0;
}
Notice: Final line of macro should not include
image.
Enter any quantity: 11 11 is odd
Pleased coding 😉