DEV Community

NilufarBukhorova
NilufarBukhorova

Posted on

5 1

C++da Operators

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay