Write a c program to demonstrate pre-processor directives Macros

 #include <stdio.h>


// Define a macro for a constant

#define PI 3.14159


// Define a macro for a function-like macro

#define SQUARE(x) ((x) * (x))


// Conditional compilation

#define DEBUG 1


int main() {

    // Using the constant macro

    printf("Value of PI: %f\n", PI);


    // Using the function-like macro

    int num = 5;

    printf("Square of %d: %d\n", num, SQUARE(num));


    // Conditional compilation

    #if DEBUG

        printf("Debug mode is ON\n");

    #else

        printf("Debug mode is OFF\n");

    #endif


    return 0;

}


Comments

Popular posts from this blog

Write a c program to Create a Circular Linked list and perform Following Operations A. Insertion At Beginning B. Insertion At End C. Insertion After a particular node Insertion Before a particular node E. Insertion at specific position F. Search a particular node G. Return a particular node H. Deletion at the beginning I. Deletion at the end J. Deletion after a particular node K. Deletion before a particular node L. Delete a particular node M. Deletion at a specific position

Write a c program to check whether the created linked list is palindrome or not

Write a c program to Create a Circular single Linked list and perform Following Operations A. Insertion After a particular node B. Insertion Before a particular node C. Search a particular node D. Return a particular node E. Deletion before a particular node F. Delete a particular node