CodesJava

Easy learning with example program codes

c preprocessor define


C #define:

A macro value in C replaces a part of a program with a value already defined by #define directive.

Syntax:

#define macro_Name macro_Value

Example:

#include<stdio.h>  
#define PI 3.14  
void main()
{    
printf("PI :%f\n",PI );    
printf("Date :%s\n", __DATE__ );    
printf("Time :%s\n", __TIME__ );    
printf("Line :%d\n", __LINE__ );    
printf("STDC :%d\n", __STDC__ ); 	 
}

Output

PI :3.140000
Date :Sep 19 2018
Time :11:43:00
Line :8
STDC :1
Posted in C   
Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki