मराठी

Differentiate between the following: Increment and Decrement operators

Advertisements

प्रश्न

Differentiate between the following:

Increment and Decrement operators

फरक स्पष्ट करा
Advertisements

उत्तर

Increment Operator

Decrement Operator

1. The increment operator is a unary operator used to increase the value of a variable by 1.

1. The decrement operator is a unary operator used to decrease the value of a variable by 1.

2. The increment operator adds 1 to the current value of a variable.

2. The decrement operator subtracts 1 from the current value of a variable.

3. The increment operator is represented by two consecutive plus signs (++).

3. The decrement operator is represented by two consecutive minus signs (--).

4. The increment operator can be used in two forms: pre-increment (++a) and post-increment (a++).

4. The decrement operator can be used in two forms: pre-decrement (--a) and post-decrement (a--).

5. In pre-increment, the value is increased before being used, whereas in post-increment, the original value is used before increasing it.

5. In pre-decrement, the value is decreased before being used, whereas in post-decrement, the original value is used before decreasing it.

6. The increment operator is commonly used to increase counters in loops and other repetitive operations.

6. The decrement operator is commonly used to decrease counters in loops and other repetitive operations.

7. Example: If a = 10, then a++; increases the value of a to 11.

7. Example: If a = 10, then a--; decreases the value of a to 9.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३२]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 6 Variables and Expressions
EXERCISE | Q 30. (e) | पृष्ठ १३२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×