Arithmetic Operators, Types of Operators, C Language Assignment Help

Assignment Help: >> Operators >> Arithmetic Operators, Types of Operators, C Language

Arithmetic Operators

C provides all the basic arithmetic operators. These can operate on any built in data type allowed in C. The unary minus operator, in effect, multiplies its single operand by -1. Therefore, a number preceded by a minus sign changes its sign.

SNO

Operator

Meaning

1.        

+(Plus)

Addition or unary plus

2.        

-(Minus)

Subtraction or unary minus

3.        

*(Multiply)

Multiplication

4.        

/(Divide)

Division

5.        

% (Remainder)

Modulo Division

 

Let us take an example if a and b are integers, then a=10 and b=3 we have the following results:

a-b =7

a+b=13

a*b=30

a/b=3 (Decimal part truncated due to both integer variable)

a%b=1 (Remainder of Division)

Similarly, during modulo division, the sign of the result is always the sign of the first operand. i.e.

10 % 3 = 1

10 %-3= 1

-10% 3= -1

-10%-3=-1

 

Integer Arithmetic

When both the operands in a single arithmetic expression such as a+b are integers, the expression is called an integer expression, and the operation is called integer arithmetic. Integer arithmetic always yield an integer value.

 

Real Arithmetic

An arithmetic operation involving only real operands is called real arithmetic. Let us take an example, if a, b and c are floats, then we will have

a= 10.0/3.0 =3.333333

b=1.0/3.0=0.333333

c=2.0/3.0=0.666666

The operator % cannot be used with real operands.

 

Mixed Mode Arithmetic

When one of the operand is real and the other is integer, the expression is called a mixed mode arithmetic expression. If either operand is of the real type, then only the real operation is performed and the result is always a real number. Thus

10/3.0 = 3.333333

10.0/3=3.333333

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd