DEV Community

kenccik
kenccik

Posted on

Inreament & Decrement Operators

Inrement bu operator bu qoshish degani bu operatorlar juda qiyin hisoblanadiBu operatorlarni hozir man qisqaxha tushuntirib ketaman Incrementdan boshlaymiz bu operator bittaga kopayish degan ma'noni anaglatadi, man buni hozir misolda korsataman.

#include <iostrema>
using namespace std;
int main () {
x = 5;
x++
return 0;
}
Enter fullscreen mode Exit fullscreen mode

bu incrementga, endi man decrementga korsataman.

#include <iostrema>
using namespace std;
int main () {
x = 5;
x--
return 0;
}
Enter fullscreen mode Exit fullscreen mode

kein +, va - ishoralari oldida va orqasida kelishi mumkin ularning asosiy farqi bu agar oldida kelsa bu (++x) bunda javobi ozida chiqaradi misol uchun

#include <iostream>              
using namespace std;
int main () {
x = 5;
++x  //6}
Enter fullscreen mode Exit fullscreen mode

agar + yokki - orqasidan kelsa bu holda uni saqlab oladi hozir man buni misolda korsataman.

#include <iostream>              
using namespace std;
int main () {
x = 5;
x++  //5
++x //7
}
Enter fullscreen mode Exit fullscreen mode

Bu holda uni saqlab olib keyingisiga qoshadi.

Top comments (0)