DEV Community

Sherzod5048
Sherzod5048

Posted on

C++ da operatorlar

  • Increment/Decrement operatorlar "++" va "--" operatorlari o'zgaruvchidagi qiymatni bittaga oshiradi yoki kamaytiradi.
#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;
  ++n;

  cout << n;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode
6
Enter fullscreen mode Exit fullscreen mode

qiymatni bittaga oshiradi yoki kamaytiradi.

#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;
  --n;

  cout << n;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode
4
Enter fullscreen mode Exit fullscreen mode

Agar kadimizda Increment/decrement o'zgaruvchidan oldin kelsa birinchi bo'lib Increment/decrement hisoblanib keyin boshqa buyruqlar bajariladi:

#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;

  cout << ++n << endl;
  cout << n;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode
6
6
Enter fullscreen mode Exit fullscreen mode

Lekin kadimizda Increment/decrement o'zgaruvchidan keyin kelsa birinchi bo'lib boshqa buyruqlar bajarilib keyin Increment/decrement hisoblaniladi:

#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;

  cout << n++ << endl;
  cout << n;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode
5
6
Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more