Easy learning with example program codes

C Macros

C Macros:

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

Macros can be of four types:

Object-like Macros:

When a macro is simply replaced by a value, then it is called as Object like Macro.


#define macro_Name macro_Value

Function-like Macros:

When a macro is replaced by a logic, same as in a function, then it is called as Function like Macro.


#define macro_Name macro_Logic

User Defined Macros:

Macros defined in a C program by the user, which are not defined in the C library are called as user defined Macros.

_DATE_ To get current date.
_TIME_ To get current time.
_FILE_ To get current file.
_LINE_ To get current line number.
_STDC_ 1

 Predefined Macros:

Some macros are already defined in the C library, these macros are called as Predefined Macros.


#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__ ); 	 
return 0;  


PI :3.140000
Date :Sep 19 2018
Time :11:43:00
Line :8
Posted in C   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki