Professional Documents
Culture Documents
C - Operators
C - Operators
NewStudents 6
OldStudents 21
TotalStudents 27
- subtraction ans = 7 - 3; 4
* multiplication ans = 7 * 3; 21
/ division ans = 7 / 3; 2
% modulus ans = 7 % 3; 1
Example 1 Example 2
A=1, B=3; A=1, B=3;
A=++B; // A is 4, B is 4 A=B++;// A is 3, B is 4
Example 1, B is increased before its value is assigned to A.
Example 2, the value of B is assigned to A and B is later
increased.
int X = 40 , Y= 10 , Z = 6,W;
W= X-Y/4 + Z++;
44
cout<<setw(6)<<W<<endl;
21
cout<<setw(6)<<Z<<endl;
W= ++X/2 + Z%2;
cout<< setw(6)<<X<<endl;
cout<<setw(6)<< W<<endl;
(C) Copyright 2020 by Prof.Abeer El_korany
35