C Program to implement the usage of basic preprocessor directives..

First, Create a seperate new file named newfile.c

#include<stdio.h>

void input(int *x,int *y)
{
    printf("\nEnter any two numbers..");
    scanf("%d%d",x,y);
}

And then,you can include this file in another c file using #include"newfile.c" as follows..

#include<stdio.h>
#include"newfile.c" //File Inclusion ..

#define maxi(a,b) (a>b?a:b) // Macro Expansion

void main()
{
    int a,b;
    input(&a,&b);
    printf("\nThe maximum of two numbers is..%d",maxi(a,b));

    #ifdef maxi    // Condition Compilation..

      printf("\nThe macro Maxi is defined..");
    #else
      printf("\nThe Macro Maxi is not defined..");
    #endif // maxi
}

No comments:

Post a comment