Arithmetic operators
Arithmetic operators
There are five basic arithmetic operators available in C#. These are used for addition (+), subtraction (-), multiplication (*), division (/) and modulus (%). Of these, the first four are available to almost every programming language.
There are five basic arithmetic operators available in C#. These are used for addition (+), subtraction (-), multiplication (*), division (/) and modulus (%). Of these, the first four are available to almost every programming language.
Operator | Name |
---|---|
+
|
add
|
-
|
sub
|
*
|
mul
|
/
|
div
|
%
|
modulus (used for reminder)
|
Syntax:-
int k=10,a,b,c,d,e; a=k%2; //output is 0
b=k+2; //output is 12
c=k-2; //output is 8
d=k*2; //output is 20
e=k/2; //output is 5
Comments
Post a Comment