Operators and Arithmetic Expressions in C: Computer Programming CMIS 1223
Operators and Arithmetic Expressions in C: Computer Programming CMIS 1223
Conducted by
Supun
Chamara
Thenuwara
● Assignment operator
● Arithmetic operators
● Relational operators
● Logical operators
● Bitwise operators
●
Special operators (, => .)
● Pointer operators (*)
Operator Action
+ Addition
- Subtraction
* Multiplication
/ Division (26/5=5)
% Modulo division (26%5=1, both values need to be integers)
++ Increment (a++ is Same as a=a+1 and Same as a+=1)
-- Decrement (a-- is Same as a=a-1 and Same as a-=1)
Relational and Logical Operators
c=++A+A++
c=++A+B*7/2+3
void main()
{
int A=3, B=5, c;
c=++A+B++;
printf( "A = %d, c = %d\n", A, c );
c=++A+A++;
printf( "A = %d, c = %d\n", A, c );
c=++A+B*7/2+3;
printf( "A = %d, c = %d\n", A, c );
c=(++A+B)*7/(2+3);
printf( "A = %d, c = %d\n", A, c );
c=A-- + ++A-25/5;
printf( "A = %d, c = %d\n", A, c );
}
Operator and implicit type conversion(casting)