In JavaScript, arithmetic operations are used to perform mathematical calculations and manipulate numerical values. The basic arithmetic operations include

Sno | Operator | Usage |
---|---|---|

1. | + | Addition |

2. | - | Subtraction |

3. | * | Multiplication |

4. | ** | Exponentiation (2016) |

5. | / | Division |

6. | % | Modulus (Remainder) |

7. | ++ | Increment |

8. | -- | Decrement |

- Addition (+): This operator is used to add two or more numbers together. For example, 4 + 3 will give the result of 7.
- Subtraction (-): This operator is used to subtract one number from another. For example, 10 - 3 will give the result of 7.
- Multiplication (*): This operator is used to multiply two or more numbers together. For example,4 * 3 will give the result of 12.
- Division (/): This operator is used to divide one number by another. For example, 10 / 5 will give the result of 2
- Modulus (%): This operator is used to find the remainder when one number is divided by another. For example, 10 % 3 will give the result of 1.
- Exponentiation (**): This operator is used to raise a number to a certain power. For example, 2 ** 4 will give the result of 16.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tutor Joes</title> </head> <body> <script src="js/script.js"></script> </body> </html>To download raw file Click Here

//Arithmetic Operation let a=100; let b=20; let c; c=a+b; c=a-b; c=a*b; c=a/b; c=a%b; c=2**3;//2016 c=++a; c=--b; console.log(c);To download raw file Click Here

The above code is written in JavaScript and it performs various arithmetic operations on two variables, a and b. The variables a and b are declared using the let keyword and are assigned the values 100 and 20, respectively.

A new variable c is declared using the let keyword and is used to store the result of the arithmetic operations.

The first operation is the addition of a and b and the result is assigned to c. Then the subtraction of b from a and the result is assigned to c. Then the multiplication of a and b and the result is assigned to c. Then the division of a by b and the result is assigned to c. Then the modulus of a by b and the result is assigned to c.

Then the operation 2 raised to the power of 3, which gives the result 8. Then the operation of incrementing the value of a and the result is assigned to c. Then the operation of decrementing the value of b and the result is assigned to c.

Finally, the console.log() function is used to output the final value of c to the console, which will be the result of the last operation performed, which is decrementing the value of b.

Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions