Sunday, 5 February 2012

Define Directive

Dear Visitors,
          In earlier post we tell you about the include directive.....
Today we are going to share with you knowledge about define directive.


SO FRIENDS LETS START OUR LESSON
  • The 'define' directive:- 
The 'define' directive is another important preprocessor directive. It is used to define a constant known as constant macro. A constant macro is an identifier, which is assigned a particular constant value. The value of identifier remains constant during the execution of program. Its general syntax is:
#include identifier expression  
Where
  • Identifier:-
                             Specifies the identifier (or macro name) to which the constant value is to be assigned.
  • Expression:-
                            Specified the constant value that is to be assigned to the identifier. It may be a constant value, a string or an arithmetic expression.
          For Example:-
In the following statements, PI has been assigned value 3.141593 and 'city' is assigned value Islamabad.
#define PI 3.141593
   #define city Islamabad

No comments:

Post a Comment