Thursday, September 17, 2015

VARIABLE LIFE CYCLE


        Variable is container. It contains value according to data type.
        Variable Life Cycle.
        1. Declaration of the identifier.
        2. Initialize value inside the identifier.
        3. Perform some operation. (According to question)
        4. Print identifier value.
      

        Syntax for (1) Identifier Declaration
        <data type> <space> <identifier name >;
        Example:-
        int roll;

        Syntax for (2) Initialize value inside the identifier.
        <identifier> <assignment operator> <value >;
        Example:-
        roll=1001;
        Syntax for (4) Print identifier value.
        <name of the output function > <("<format specifier>", <identifier as a argument >)>;
        Example: -
        printf("%d",roll);
        Syntax for (4) Print identifier value with message.
        <name of the output function> <("<message><format specifier>",<identifier as a argument>)>;
        Example:-
        printf("Roll=%d",roll);
        .........................................................................................................
       

To declare more than one variable with same data then use comma operator to separate each identifier.
        Syntax for - More than one variable with same data type.
        <data type> <space> <identifier><comma><identifier><comma> ................ ;
        Example: -
        int fnumber,snumber;
        To print more than one identifier value
        syntax:-
      <name of the output function> <("<format specifier><format specifier>",<identifier as a argument><identifier as a argument>)>;
        Example: -
                     printf("Fnumber=%d\nSnumber=%d",fnumber,snumber);

0 comments:

Post a Comment