Thursday, November 21, 2013

                Increment And Decrements Operator : prefix and postfix



  • In the Increasing a value by 1(n+1) is called incremented
  • Decreasing value by 1(n-1) is called decremented
  • As 1 is the most common value used to add, subtract into variable. 
  • The increment operator(++) increases the variable's value by 1 and the decrements operator(--) decreases the value by 1.

    #include <iostream>
    int main ()
    {
        using std::cout;
        using std::endl;
        int b = 4, c = 7;
        cout << "The value of b is : " << b << endl;
        b = b + 1;
        cout << "The value of b is : " << b << endl;
        b += 1;
        cout << "The value of b is : " << b << endl;
        b++;
        cout << "The value of b is : " << b << endl;
        cout << endl;
        cout << "The value of c is : " << c << endl;
        c = c - 1;
        cout << "The value of c is : " << c << endl;
        c -= 1;
        cout << "The value of c is : " << c << endl;
        c--;
        cout << "The value of c is : " << c << endl;
        return 0;
    }




    2 comments:

    1. Hello..sir what it is topic? you say name topic give me pls

      ReplyDelete
    2. You must see head topics... Increment And Decrements Operator

      ReplyDelete