Close
Close

INCREMENT AND DRECREMENT

   lataraju

difference between a++ and ++a is not clear . if a++ is there why we need ++a n vice versa. GIVE EXAMPLE WITH APPLICATION. IAM NEW TO C . :)


Answers

  •   

    At times we need to use ++a. 

    int a = 1;
    int b;
    int c;
    
    1.  b = a++;
    2.  c = ++a;
    

    In the first statement, the value of b is 1. First, b = a, then there is an increament in the value of a, so a becomes 2.

    On the other hand, the value of c becomes 2 becuse first c is taking the increased value of a. Also, a becomes 2 in both of the cases.

    Hope you have understood the difference now. Feel free to comment down any further doubts.



Ask Yours
Post Yours
Write your answer