Arithmetic operators are used to the total of numeric operands or string concatenation and save in a variable.

Arithmetic Operators

Operator Meaning

+ Addition (used to add two number)

– Subtraction (used to subtraction)

* Multiplication (used to multiply)

/ Division(used to divide)

% Modulus Operator (used to find remainder

Examples of arithmetic operators are

a=c + d

a=c - d

a=c * d

a=c / d

a=c% d

etc., here a,c,d are known as operands. The % is used in this expression to find the remainder of the operands after division.

Example

#include<stdio.h> //header file

#include<conio.h> //header file

void main() //the start of the program

{

int c, d, total, sub, mul, div, mod; //declaration of variables

scanf (“%d %d”, &c, &d); //inputs the operands

total = c+d; //addition of numbers and store in total.

printf(“\n Thu total is = %d”, total);

sub = c-d; //subtraction of numbers and store in sub.

printf(“\n Thu difference is = %d”, sub);

mul = c*d; //multiplication of numbers and store in mul.

printf(“\n Thu product is = %d”, mul);

div = c/d; //division of numbers and store in div.

printf(“\n Thu division is = %d”, div);

mod = c%d; //modulus of numbers and store in mod.

printf(“\n Thu modulus is = %d”, mod);

getch();

}

Integer Arithmetic

When we do an arithmetic operation numbers or integers than this operation is called as integer arithmetic. It gives the integer as the result. Suppose c = 25 and d = 7 be 2 integer numbers. Then the integer operation leads to the following results.

c + d = 32

c - d = 18

c * d = 175

c / d = 4

c % d = 4

Ex:-

-19% 3 = -1

-19%-3 = -1

19%-3 = 1

In integer division the fractional part is truncated.

Floating point arithmetic

When we perform operation on two real numbers or fraction numbers then this operation is called floating point arithmetic.

Let x = 15.0 and y = 3.0 then

x + y = 18.0

x – y = 12.0

x * y = 545.0

x / y = 3.00

#include<stdio.h>

Void main ()

{

int a=10;

float b=15,c,d,e,f;

c=a+b;

d=a-b;

e=a*b;

f=b/a;

printf(“%f”,c);

printf(“%f”,d);

printf(“%f”,e);

printf(“%f”,f);

getch();

}

Mixed mode arithmetic

When one operand is real number and other is an integer number. Then operation between these operands called as mixed mode arithmetic. If any one operand is of real type then the result will always be real thus 15/10.0 = 1.5

#include<stdio.h>

Void main ()

{

int a=10;

float b=15,c;

c=b/a;

printf(“%f”,c);

getch();

}

Difference between Photoshop and illustrator

2016:08:30

Digital Marketing can Boost your Business

2016:08:30

Effective ways to Communicate with Business Prospe

2016:08:30

AQUASPADE Private Limited 5, AJ Serene, Ram Indu Park, Near Sapling Nursery School, Baner, Pune - 411045, Maharashtra, India.

AQUASPADE Private Limited NO.5, 17/F Bonham Trade Centre
50 Bonham Strand, Sheung Wan Hong Kong.

## Comments (0)