Preprocessor Directives in C
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// Program for Preprocessor diretive
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#define SIZE 10
# define AND &&
# define OR ||
int main()
{
system("cls");
int a[SIZE],i;
printf("Enter element in array");
for(i=0;i<SIZE;i++)
scanf("%d",&a[i]);
for(i=0;i<SIZE;i++)
printf(" %d ",a[i]);
return 0;
}Program 2
// Program for macro with argument
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#define add(a,b) a+b
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
int main()
{
int a,b,c;
system("cls");
printf("Enter two number");
scanf("%d%d",&a,&b);
// c=add(a,b);
// printf("Addition is %d",c);
c=max(a,b);
printf("%d",c);
return 0;
}Program 3
// Program for macro with argument
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#define area(r) 3.14*r*r
int main()
{
float r,A;
system("cls");
printf("Enter redious");
scanf("%f",&r);
A=area(r);
printf("Area is %.2f: ",A);
return 0;
}
Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

