-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost_pre_inc_dec.cpp
More file actions
22 lines (21 loc) · 872 Bytes
/
post_pre_inc_dec.cpp
File metadata and controls
22 lines (21 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int main()
{
int num = 48;
cout << " The number is : " << num << endl;
num++; // increase by 1 (post-increment)
cout << " After post increment by 1 the number is : " << num << endl;
++num; // increase by 1 (pre-increment)
cout << " After pre increment by 1 the number is : " << num << endl;
num = num + 1; // num is now increased by 1.
cout << " After increasing by 1 the number is : " << num << endl;
num--; // decrease by 1 (post-decrement)
cout << " After post decrement by 1 the number is : " << num << endl;
--num; // decrease by 1 (pre-decrement)
cout << " After pre decrement by 1 the number is : " << num << endl;
num = num - 1; // num is now decreased by 1.
cout << " After decreasing by 1 the number is : " << num << endl;
cout << endl;
return 0;
}