0% found this document useful (0 votes)
4 views2 pages

C++ Increase and Decrease Operators

Uploaded by

lysarith09
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

C++ Increase and Decrease Operators

Uploaded by

lysarith09
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C++ លំហាត់ Increase and Decrease Operators

1. Increase Operators (++): កំណ ើន


1.1. Pre-Increase Operators: ណកន
ើ មុន
C++ Code:
#include<iostream>
using namespace std;

int main(){
//Increase Operators
//Pre-Increase (++)
int x;
x = 20;
cout << "x: " << x << endl;//x: 20
cout << "x: " << ++x << endl;//x: 21
cout << "x: " << x << endl;//x: 21
return 0;
}
Output:

1.2. Post-Increase Operators: ណកន


ើ ណរោយ
C++ Code:
#include<iostream>
using namespace std;

int main(){
//Increase Operators
//Post-Increase (++)
int x;
x = 20;
cout << "x: " << x << endl;//x: 20
cout << "x: " << x++ << endl;//x: 20
cout << "x: " << x << endl;//x: 21
return 0;
}
Output:

2. Decrease Operators (--): ថយ


2.1. Pre-Decrease Operators: ថយមុន
C++ Code:
#include<iostream>
using namespace std;

int main(){
//Decrease Operators
//Pre-Decrease (--)
int x;
x = 20;
cout << "x: " << x << endl;//x: 20
cout << "x: " << --x << endl;//x: 19
cout << "x: " << --x << endl;//x: 18
cout << "x: " << x << endl;//x: 18
return 0;
}
Output:

2.2. Post-Decrease Operators: ថយតាមណរោយ


C++ Code:
#include<iostream>
using namespace std;

int main(){
//Decrease Operators
//Post-Decrease (--)
int x;
x = 20;
cout << "x: " << x << endl;//x: 20
cout << "x: " << x-- << endl;//x: 20
cout << "x: " << x-- << endl;//x: 19
cout << "x: " << x << endl;//x: 18
return 0;
}
Output:

You might also like