Operatorlar ikkiga turga bo'linib, ular quyidagilar:
binary(+,/,*,-)
unary
Arithmetic operators
/ amalini bajarayotganda, ma'lumotni turi muhim bo'lib, kasr son kasr songa, butun son butun songa bo'linayotganini bilish kerak, yo'qsa misolni javobida o'zgarish bo'ladi.
modulus faqat butun sonlar ustida amallarni bajaradi.
amallar matematika bn bir xildek ketma ketlikda bajariladi.
-
shortcuts
- a += 1
- a *(/, -, %)= 4
- faqat ushbu qiymatlar uchun shortcut mavjud:
- * a += 1* --> a++;
- * a -= 1* --> a--;
Danger
++x
--> increase x by 1 and do other operations
x++
--> do other operations and increase by 1
--x
--> decrease x by 1 and do other operations
x--
--> do other operations and decrease by 1
- sample int x =5; int y =x++;
cout << x << y << endl;
after running, the answer is---> 6 5
Relational operator
- relationship between left and right sides
- result is always either True(1) or False(0)
-
operators
-- <, <=, ==, >=, >, !=
Logical operators
- !=not
- &&=and--> hammasi to'g'ri bo'lishi shart.
- ||=or --> 1tasi to'g'ri bo'lsa ham, hisobga o'taveradi.
Top comments (0)