Arithmetic Operators


Arithmetic Operators

Operators are special symbols in the C programming language used to execute a variety of mathematical and logical operations on the operands and return the desired results. Arithmetic Operators, Relational Operators, Shift Operators, Logical Operators, Bitwise Operators, Ternary or Conditional Operators, and Assignment Operators are all available in the C programming language. However, this article will look at the Arithmetic Operator in the C programming language.

The Arithmetic Operator is used to execute mathematical operations includes addition, subtraction, multiplication, division, modulus, etc.

Examples of arithmetic operators are 5 + 3 = 8, 5 - 3 = 2, 2 * 4 = 8, and so on. Let's look at the many forms of Arithmetic Operators in C programming.

Syntax

operands_one + operands_two; operands_one - operands_two; operands_one * operands_two; operands_one / operands_two; operands_one % operands_two;

Plus Operator

It's a basic Plus (+) Operator used to combine two operands. To add the provided operand, we may use the Plus Operator with many data types such as integer, float, long, double, enumerated, and string data.

Syntax

C = A + B; for example: there are two operands, 5 and 6, and we wish to sum them. As a result, between the supplied numbers that yield integer data, we apply the '+' Operator 11.

Minus Operator

The negative (-) sign represents the minus operator, and it's used to get the result of subtracting the first integer from the second. In the computer language, the data type of the provided number might be several kinds such as int, float, double, long double, and so on.

For example, there are two operands, 15 and 6, and we want the result of their subtraction. So, between the provided integers that produce data 9, we apply the '-' Operator.

Example:

#include <iostream> using namespace std; int main() { int a=10,b=20; cout<<"\n a+b:" <<a+b; cout<<"\n a-b:" <<a-b; cout<<"\n a/b:" <<a/b; cout<<"\n a%b:" <<a%b; cout<<"\n a*b:" <<a*b; return 0; }

OUTPUT:

opertor type