Wednesday, August 26, 2020

9.1.3 Arithmetic Operators

  • Arithmetic operators are used to perform mathematical operations. 
  • Such as addition, subtraction, division and multiplication etc. 
  • Arithmetic operators are of 5 types. These are basic mathematical operators.

Operators

Description

+ (Addition)

This operator adds values of two variables.

– (Subtraction)

This operator subtract the value of one variable from the value

of one variable.

* (Multiplication)

This operator multiply values of 2 variables.

/ (Division)

This operator divides the value of one variable from the value

of another variable.

% (Modulus)

It is used to obtain the remaining value after the operator

division.



EXAMPLE :-


// Arithmetic operators in C.
#include <stdio.h>

int main() {

// variable declaration
int opr1, opr2, sum;
// variable definition
opr1 = 3;
opr2 = 4;
// addition operation
sum = opr1 + opr2;
printf("sum of %d and %d is %d", opr1, opr2, sum);
}


OUTPUT

sum of 3 and 4 is 7

No comments:

Post a Comment

Please do not any spam link in Comment Box