- 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;
}
6
qiymatni bittaga oshiradi yoki kamaytiradi.
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int n = 5;
--n;
cout << n;
return 0;
}
4
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;
}
6
6
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;
}
5
6
Top comments (0)