How to write multiline macro in C language? – Codeforwin

How to write multiline macro in C programming language. We typically outline macros that spans over single line. However there exists conditions whenever you need to outline a macro that spans over a number of line.

In this put up I’ll clarify how to write a multiline macro in C language. So allow us to get began.


Required data

Basic C programming, Preprocessor directives, Macros

During the course of macros programming workout routines, we learnt fundamentals of macros. How to outline and undefine a macro. In this put up we are going to continue forward with macro and will be taught to outline multiline macro.

For a lot of the instances macros are candy and short, prolonged upto single line. However, typically we outline difficult macros that spans over a number of traces. Defining these macros in single line will lose code readability, therefore we outline multiline macro .

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 examine and print even odd quantity
#outline EVEN_ODD(num)               
    if (num & 1)                    
        printf("%d is oddn", num); 
        printf("%d is evenn", num);

int most important()

    int num;

    // Input quantity from consumer
    printf("Enter any number: ");
    scanf("%d", &num);


    return 0;

Note: Last line of macro should not comprise image.

Enter any quantity: 11
11 is odd

Happy coding 😉


Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *


You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.