Increment/Decrement
- o'zgaruvchining qiymatini 1ga oshirish (++) yoki kamaytirish (--) uchun ishlatiladi
int x = 10;  // x = 10
int y = x++;    // y = 10, x = 11
int z = x++ + y++; // z = 21, x = 12, y = 11
cout << x << endl;
cout << y << endl;
cout << z << endl;
- postfix usulida increment/decrement o'zgaruvchidan keyin keladi va operator ustunligi juda past bo'ladi.
Masalan: x = y++; ifodasida increment operatori o'zgaruvchidan keyin kelgani sababli o'zlashtirish operatori birinchi bajariladi
    int x = 5;
    int y = x++;
    cout << x << endl; // 6
    cout << y << endl; // 5
- prefix usulida increment decrement o'zgaruvchidan oldin keladi va operator birinchi bajariladi
Masalan: x = ++y; ifodasida increment operatori o'zgaruvchidan avval kelgani sababli increment operatori birinchi bajariladi.
    int x = 5;
    int y = ++x;
    cout << x << endl; // 6
    cout << y << endl; // 6
| Assignment | Compound | |
|---|---|---|
| x = x + 1 | x += 1 | |
| x = x - 1 | x -= 1 | |
| x = x * 1 | x *= 1 | |
| x = x / 1 | x /= 1 | 
 
 
              
 
    
Top comments (0)